• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 727
  • Last Modified:

Loading and unloading AppDomains and Assemblies

Is there a way to load an assembly into an AppDomain other than the current AppDomain using the file path to the assembly? I need to be able to load and unload assemblies, so I assumed that the best way to do this is with AppDomains, but I haven't been able to make it work. I need to be able to load an assembly into a newly created AppDomain, get a proxy to a type in the assembly, call methods on the proxy, then unload the AppDomain. And I need to be able to do this all without loading the assembly into the local AppDomain. There must be a way to do this, but I haven't figured it out yet. Does somebody know how to do this? Thanks!
0
Paracom_Inc
Asked:
Paracom_Inc
  • 2
1 Solution
 
steveberzinsCommented:
This looks like a pretty good description and guide, with some sample code available.

http://www.devsource.com/article2/0,1759,1790388,00.asp

0
 
Paracom_IncAuthor Commented:
The article doesn't specifically answer my question, but it is a great article on the related topic of loading and unloading code. Thanks. By the way, it appears that the simple answer to my question is no. Only Assembly.LoadFile() appears to take a file path as a parameter. The AppDomain methods that load an assembly do so by assembly FullName.
0
 
steveberzinsCommented:
sorry, missed that part of the question...

if you look at the overload of AppDomain.CreateDomain that takes a parameter of type AppDomainSetup, you can use an AppDomainSetup to not only specify the path, but specify a separate config file, whether and where to shadow copy...

AppDomainSetup ads = new AppDomainSetup();

ads.ApplicationBase = <<path to assembly>> //directory ending in \, each assembly needs to be in it's own directory as far as I know.
ads.ConfigurationFile = <<nameofconfigfile>>
ads.CachePath = <<path you want to use for shadow copies>>
ads.ShadowCopyFiles="true"

then a call like this, rather than than using the overload that uses only name.

AppDomain ad = AppDomain.CreateDomain(<<domainname>>, AppDomain.CurrentDomain.Evidence, ads);

next time don't give a bad grade if you didn't get your answer, or all of what you were looking for, clarify your needs, give a guy a chance, and we'll get you the answer worth an 'A', and we all win. :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now