Reputation: 1670
I tried the below code to load and unload managed assemblies.
AppDomain dom = AppDomain.CreateDomain("some");
AssemblyName assemblyName = new AssemblyName();
assemblyName.CodeBase = pathToAssembly;
Assembly assembly = dom.Load(assemblyName);
Type [] types = assembly.GetTypes();
AppDomain.Unload(dom);
however, i got an exception "Friendlyname or appdomainbase invalid ", while loading the assembly into the appdomain. Can anyone help me
Upvotes: 1
Views: 151
Reputation: 42363
As the exception implies - it's just that it can't find the assembly.
You need to need to use the AppDomainSetup type when creating the AppDomain and set the ApplicationBase
to the folder where you want it to probe for assemblies when using the Load
method. You can also set the PrivateBinPath
as well for additional paths.
This other MSDN topic (linked from the previous one) gives an example.
Providing a CodeBase
in the AssemblyName will not work.
Upvotes: 1