문제

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