Can I just use?:
Assembly.LoadFile
Not sure if this is the way to do this?
But when I try that approach, it throws a Could not load file or assembly "CustomControlLib"
or one of its dependencies. The system cannot find the file specified.
Any ideas?
1. EXE is an extension used for executable files while DLL is the extension for a dynamic link library. 2.An EXE file can be run independently while a DLL is used by other applications. 3.An EXE file defines an entry point while a DLL does not.
An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. Assemblies take the form of executable (.exe) or dynamic link library (. dll) files, and are the building blocks of . NET applications.
NET Framework when we compile a Console Application or a Windows Application, it generates EXE, whereas when we compile a Class Library Project or ASP.NET web application, then it generates DLL. In.NET framework, both EXE and DLL are called assemblies.
An assembly is a collection of one or more files and one of them DLL or EXE. DLL contains library code to be used by any program running on Windows. A DLL may contain either structured or object oriented libraries. A DLL file can have a nearly infinite possible entry points.
You will need to make sure that the dependencies are also loaded into the app domain. If they aren't located automatically, you can subscribe to AppDomain.AssemblyResolve
in order to find and load assemblies manually if needs be.
For example:
private Assembly AssemblyEventHandler(object sender, ResolveEventArgs args)
{
return locatedAssembly;
}
Also, I would consider using Assembly.LoadFrom
, particularly after reading this which has a strong assertion by nobugz and links to some good reading (all dated but ought to still be withstanding for the most part.)
If you use Assembly.LoadFrom()
dependencies will be loaded from the directory where assembly is located.
Assembly.LoadFile()
is ignoring all other DLLs and exe files in the same folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With