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



Question:

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!


Solution:1

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


Solution:2

If you want to know if it was a .exe or a .dll, you can check Assembly.Location.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »