Paracom_Inc
asked on
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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(<<d omainname> >, AppDomain.CurrentDomain.Ev idence, 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. :)
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(<<d
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. :)
ASKER