zl程序教程

您现在的位置是:首页 >  其它

当前栏目

Getting wrong Version from Assembly using Reflection

from Using version Getting Wrong assembly reflection
2023-09-11 14:14:18 时间

Getting wrong Version from Assembly using Reflection

dotpeek does not have any magic here. It's just a very-very confusing name and behavior for Assembly.LoadFile(string path) method. Assembly.LoadFile() does not actually load the assembly at specified path, it would prefer GAC like described here. You could check the actual path of loaded assembly with ProcessExplorer or similar tool.

If you want to load assembly at exact path for reflection purposes, it's better to use Assembly.ReflectionOnlyLoadFrom() method:

Assembly assembly = Assembly.ReflectionOnlyLoadFrom(f);

In this case assembly.GetName().Version should give you the correct assembly version.