Skip Navigation LinksHome > Blog > 2008 > January > 02 > How To: Load Assemblies in an Application Domain

How To: Load Assemblies in an Application Domain

Creating a new application domain and launching an assembly within that domain is as simple as creating an instance of the System.AppDomain class with a friendly name, and then calling the ExecuteAssembly method, as the following code demonstrates:

' VB
Dim d As AppDomain = AppDomain.CreateDomain("NewDomain")
d.ExecuteAssembly("Assembly.exe")

Excerpt from MSDN:

There are several ways to load an assembly into an application domain. The recommended way is to use the static (Shared in Visual Basic) Load method of the System.Reflection.Assembly class. Other ways assemblies can be loaded include:

  • The Load method of the System..::.AppDomain class can load assemblies, but is primarily used for COM interoperability. It should not be used to load assemblies into an application domain other than the application domain from which it is called.