Advertisement

02.04.2008 at 10:23PM PST, ID: 23137263
[x]
Attachment Details

Load assembly from a file into app domain

Asked by gromul in C# Programming Language, Microsoft Visual C#.Net, Visual Studio .NET 2005

How do I load assembly from a file into app domain? I need to load into a non-current app domain so I could unload the domain (and the loaded assembly in it) and then load another version of the assembly.

Here's what I have so far:

AppDomainSetup appDomainSetup = new AppDomainSetup( );
AppDomainSetup appDomainSetup.ShadowCopyFiles = "true";
AppDomainSetup appDomainSetup.ApplicationBase = @"c:\Documents and Settings\user\Local Settings\Temp";

AppDomain appDomain = AppDomain.CreateDomain( "Test", null, appDomainSetup );
string filePath = @"C:\Documents and Settings\user\Local Settings\Temp\Test.dll";
string typeName = "Test.TestAssembly";
object o = appDomain.CreateInstanceFromAndUnwrap( filePath, typeName );

The latest error I'm getting is "Type is not resolved for member 'Test.TestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'".

Thanks
Start Free Trial
[+][-]02.05.2008 at 03:59AM PST, ID: 20822187

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.05.2008 at 10:38AM PST, ID: 20825492

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.06.2008 at 02:41AM PST, ID: 20830877

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Microsoft Visual C#.Net, Visual Studio .NET 2005
Sign Up Now!
Solution Provided By: gbzhhu
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628