سؤال

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