简体   繁体   中英

How to be sure that Assembly.LoadFrom really loads a DLL file in?

I'm trying to add my plugins to my application via Assembly.LoadFrom and I would like to know if there's a property to know what type of assembly was loaded - dynamically linked library and executables can be loaded, right?

Thank you!

You can determine whether the Assembly returned by the LoadFrom function has loaded an EXE or DLL using the Assembly.EntryPoint property. If the property returns a MethodInfo for the entry point function, then you are dealing with an EXE.

From MSDN:

Type: System.Reflection.MethodInfo An object that represents the entry point of this assembly. If no entry point is found (for example, the assembly is a DLL), null is returned.

http://msdn.microsoft.com/en-us/library/system.reflection.assembly.entrypoint.aspx

如果您想知道它是.exe还是.dll,则可以检查Assembly.Location

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM