本文介绍了AppDomainSetup.ApplicationBase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在与主应用程序不同的AppDomain中运行一些代码.该代码及其依赖项位于主应用程序的AppBase目录之外.
I want to run some code in a different AppDomain than main application. That code and its dependencies are located outside of AppBase directory of main application.
例如,MainApp.exe从C:/MainApp运行,而其他代码"从C:/MainApp运行.位于c:\ TestApp中.我使用这段代码
For example, MainApp.exe runs from C:/MainApp and "other code" is located in c:\TestApp. I use this code
AppDomainSetup ads = new AppDomainSetup();
ads.ApplicationBase = @"C:\TestApp";
AppDomain ad = AppDomain.CreateDomain("My Own Domain", null, ads);
ad.ExecuteAssembly("TestApp.exe");
,但是CLR仍在主应用程序BaseDirectory c:\ MainApp下寻找TestApp.exe.如何在c:\ TestApp下查找TestApp.exe及其依赖项?
but CLR still looks for TestApp.exe under main app BaseDirectory c:\MainApp. How can I make it look for TestApp.exe and its dependencies under c:\TestApp?
谢谢.
推荐答案
AppDomainSetup lAds = new AppDomainSetup();
lAds.ApplicationBase = @"C:\11\";
AppDomain lNewDomain = AppDomain.CreateDomain("OtherAppToRun Domain", null, lAds);
lNewDomain.ExecuteAssembly("C:\\11\\OtherAppToRun.exe");
这篇关于AppDomainSetup.ApplicationBase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!