错误:“违反了继承安全规则”沙盒时
我正在创建一个将在沙盒环境中运行代码的应用程序。此环境应该只允许不受信任的代码处理明确给出的资源并返回定义的数据类型。我使用本文中找到的主体来设置沙箱:
我还有一些需要在沙盒环境中运行的代码。不幸的是,当我尝试设置在沙箱内运行的类型时,出现以下错误:
类型违反了继承安全规则:“MyTypeRunningInSandbox”。派生类型必须与基类型的安全可访问性相匹配,或者难以访问。
我不确定为什么会收到此错误,因为基本类型和派生类型都是我创建的,并且两者都不应该比另一个更安全或更不安全。
我的应用程序结构(帮助您理解):
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 );
关于如何解决此问题的任何想法?
I'm creating an application that will run code in a sandboxed environment. This environment should only allow the untrusted code to process resources that it is explicity given and return a defined data type. I'm using the principals found in this article to setup the sandbox:
How to: Run Partially Trusted Code in a Sandbox
I also have some code that will need to run inside the sandboxed environment. Unfortunately, when I try to setup the type to run inside the sandbox I'm getting the following error:
Inheritance security rules violated by type: 'MyTypeRunningInSandbox'. Derived types must either match the security accessibility of the base type or be less accessible.
I'm not sure why I would get this error as both the base type and the derived type were created by me, and neither should be more or less secure than the other.
My Application Strucure (to help you understand):
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)
If you compare my solution with regard to the Microsoft article above, my code is failing on the equivalent to the following line:
ObjectHandle handle = Activator.CreateInstanceFrom(
newDomain, typeof(Sandboxer).Assembly.ManifestModule.FullyQualifiedName,
typeof(Sandboxer).FullName );
Any thoughts on how to troubleshoot this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于明白了这一点。我需要更好地了解可信程序集和强名称的工作原理。问题是,我的不受信任类型的基本类型位于一个程序集中,该程序集使用我之前设置为受信任的相同强名称密钥进行签名。当我将基本类型移动到具有不同强名称密钥的新程序集时,它开始工作得很好。现在看来是如此明显,无法想象为什么我以前没有看到它。
感谢任何给予此考虑的人!
I finally figured this out. I needed a better understanding of how trusted assemblies and strong names work. The problem was that my the base type for my untrusted type was located in an assembly that was signed with the same strong name key I had setup as trusted before. When I moved the base type to a new assembly with a different strong name key, it started working great. It seems so obvious now, can't imagine why I didn't see it before.
Thanks to anyone who gave this consideration!