Using App.Config

I have the following problem:

mmc.exe is the process that loads my .NET ActiveX.

The .Net ActiveX uses some assemblies that are not in the gac

I want to use app.config to configure my ActiveX with the location of the assemblies

As I understood the way to do it is is to create a new AppDomain with AppDomainSetup

and the loader automatically will use this AppDomain

Shouldn't I do something more in order to instruct the loader to use my new AppDomain

This is the code I tried without any success

AppDomainSetup s = new AppDomainSetup();
s.ApplicationBase = "g:\\tms2\\src\\mmc\\tpotab\\net\\bin\\debug\\";
s.ConfigurationFile = "g:\\tms2\\src\\mmc\\tpotab\\net\\bin\\debug\\TmsTPOManager.dll.config";
AppDomain currentDomain = AppDomain.CreateDomain(AppDomain.CurrentDomain.FriendlyName, AppDomain.CurrentDomain.Evidence, s);

Please instruct me what to do it is very important to use

Thanks Gil Fefer



Answer this question

Using App.Config

  • Andy Wigley

    Hi Gil,

    After you create your AppDomain, you need to transfer control into it. The easiest way to do this is to create an object that derives from MarshalByRefObject and do an currentDomain.CreateInstanceFromAndUnwrap() call on your new domain. The new object will then live in the new domain, and you can call a method on it to transfer control there.

    Be careful though, the assembly containing the object will have to be accessable to both your default domain and the new one -- since that means the loader has to find it with both AppBases, you'll probably have to put it in the GAC.

    -Shawn



  • Using App.Config