Have a .NET 4 WinForms App. When I try to do the following: GetAssemblyName(@"C:\Windows\assembly\NativeImages_v4.0.30319_64\mscorlib\e0e5fbe72e8813a135fc878ff32b4bee\mscorlib.ni.dll");

I get the famous "incorrect format" exception. What am I missing here?

Thanks!

有帮助吗?

解决方案

As the folder name says, the mscorlib.ni.dll is a native image. It's .NET Code compiled into native machine code, so it's not a .NET Assembly anymore, and thus you cannot use reflection on it. Why are you trying to do this? The path is used internally by the .NET Runtime.

EDIT: If you encounter such a module, you will have to handle the exception and retreive information about the module differently. Either you stick with just the file name, or you use other APIs, like System.Diagnostics.FileVersionInfo.GetVersionInfo to retreive information.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top