我正在創建一個將在沙盒環境中運行代碼的應用程序。這個環境應該只允許不受信任的代碼處理明確給定的資源並返回一個定義的數據類型。我使用這個文章中找到設置沙箱校長:錯誤:沙盒時出現「繼承安全規則違反」
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);
有關如何解決此問題的任何想法?