问题描述
嗨
我在执行应用程序域中的程序集时遇到问题
ClassLibrary1是程序集,而我仅包含一个方法TestMethod()
在此测试方法中,将访问网站"www.google.com"
如果我这样称呼它工作正常,但是我需要通过appdomain称呼它.
ClassLibrary1.Class1.TestMethod();
我的示例代码是:
Hi
I am getting a problem in executing the assembly in app domain
ClassLibrary1 is the assembly and i contains the only one method TestMethod()
In this Testmethod will access the website "www.google.com"
if i call like this its Working fine, but i need to call this through the appdomain.
ClassLibrary1.Class1.TestMethod();
my sample code is:
object[] hEvidence = {new Zone (System.Security.SecurityZone.Internet) };
Evidence AppEvidence = new Evidence(hEvidence, null);
AppDomain d = AppDomain.CreateDomain("ClassLibrary1domain");
d.ExecuteAssemblyByName("ClassLibrary1", AppEvidence);
AppDomain.Unload(d);
我在这里创建的Appdomian仅具有对Internet的访问权限
我遇到错误
Here i am creating the appdomian with only the privileges access to the Internet
i am getting the Error
Request for the permission of type ''System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'' failed.
这是什么问题,我要去哪里了.
What it is the problem, where i am going wrong.
推荐答案
这篇关于如何使用应用程序域在C#.net中执行程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!