How do I create an application domain and run my application in it?

前端 未结 2 1637
北荒
北荒 2020-12-01 01:18

I need to create a custom application domain to work around a bug in the .NET runtime\'s default behavior. None of the sample code I\'ve seen online is helpful since I don\'

2条回答
  •  猫巷女王i
    2020-12-01 01:39

    You need to:

    1) Create an instance of AppDomainSetup object and populate it with the setup information you want for your domain

    2) Create your new domain by using AppDomain.CreateDoman method. The AppDomainSetup instance with configuration parameters is passed to the CreateDomain method.

    3) Create an instance of your object in the new domain by using the CreateInstanceAndUnwrap method on the domain object. This method takes typename of the object you want to create and returns a remoting proxy you can use in yuor main domain to communicate with the object created in the new one

    Once you are through with these 3 steps you can call methods in the other domain through the proxy. You can also unload the domain after you are done and reload it again.

    This topic in MSDN help has pretty detailed example of what you need

提交回复
热议问题