我正在创建一个将在沙盒环境中运行代码的应用程序。这个环境应该只允许不受信任的代码处理明确给定的资源并返回一个定义的数据类型。我使用这个文章中找到设置沙箱校长:错误:沙盒时出现“继承安全规则违反”
How to: Run Partially Trusted Code in a Sandbox
我也有一些代码,需要将沙盒环境中运行。不幸的是,当我尝试安装类型,我发现了以下错误沙盒中运行:
Inheritance security rules violated by type: 'MyTypeRunningInSandbox'. Derived types must either match the security accessibility of the base type or be less accessible.
我不知道我为什么会得到这个错误的基本类型和派生类型两者都是由我创造,并且两者都不应该比另一个更安全。
我的应用程序Strucure(以帮助您了解):
TypeLoader class
\
Trusted Sandbox Manager (i.e. sets up a the new sandbox)
\ (the error is happening in this class while creating the
| new app domain)
|
|Untrusted Sandbox Manager (i.e. runs the untrusted code)
如果你比较我的解决方案对于Microsoft文章上面,我的代码失败在相当于以下行:
ObjectHandle handle = Activator.CreateInstanceFrom(
newDomain, typeof(Sandboxer).Assembly.ManifestModule.FullyQualifiedName,
typeof(Sandboxer).FullName);
有关如何解决此问题的任何想法?