使用 Linq-to-SQL 的中等信任 ASP.NET MVC 应用程序上的 Cassini 异常
我在尝试在 Cassini 3.5.0.2 上浏览中等信任 ASP.NET MVC 应用程序(使用 Linq-to-SQL)时收到以下异常:
Could not load file or assembly 'Cassini, Version=3.5.0.2, Culture=neutral, PublicKeyToken=da0fefd60d522a7d'
or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)
有一个内部异常:
Execution permission cannot be acquired.
Stack trace:
at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset,
PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission)
at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset,
PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission)
同一应用程序在 IIS7 和内部 VS2008 Web 服务器上运行。 Cassini 与不使用 Linq-to-SQL 的 ASP.NET MVC 应用程序一起工作没有任何问题。
ASP.NET MVC 应用程序和 Linq-to-SQL 存储库项目都应用了 [程序集:System.Security.AllowPartiallyTrustedCallers]
,以便在中等信任度下工作。
有人对这个问题有任何线索吗?
编辑
Server.cs
中的这一行引发异常:
return appManager.CreateObject(appId, hostType, virtualPath, physicalPath, false);
I am receiving the following exception trying to browse a medium trust ASP.NET MVC application (using Linq-to-SQL) on Cassini 3.5.0.2:
Could not load file or assembly 'Cassini, Version=3.5.0.2, Culture=neutral, PublicKeyToken=da0fefd60d522a7d'
or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)
with an inner exception:
Execution permission cannot be acquired.
Stack trace:
at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset,
PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission)
at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset,
PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission)
The same application works on IIS7 and on internal VS2008 web server. Cassini works without any problems with ASP.NET MVC application which are not using Linq-to-SQL.
Both the ASP.NET MVC application and the Linq-to-SQL repository project have [assembly: System.Security.AllowPartiallyTrustedCallers]
applied in order to work in medium trust.
Has anyone any clue about this problem?
EDIT
The exception is thrown on this line from Server.cs
:
return appManager.CreateObject(appId, hostType, virtualPath, physicalPath, false);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[ http://blogs.msdn.com/dmitryr/archive/2009/04/23/cassini-support-for-friend-urls-routing.aspx#9855758]
不幸的是,这是单一的副作用-EXE卡西尼号。 在工作应用程序域中,Cassini EXE 被视为不受信任的代码。
为了使其在中等信任中工作,您需要修改中等信任定义(以允许由您的密钥签名的程序集获得完全信任)或返回将 Cassini 放入 GAC,就像以前的版本一样。
谢谢,
德米特里
[http://blogs.msdn.com/dmitryr/archive/2009/04/23/cassini-support-for-friendly-urls-routing.aspx#9855758]
Unfortunately this is a side-effect of the single-EXE Cassini. In the worker app domain Cassini EXE is treated as untrusted code.
To make it work in Medium trust, you need either tinker with Medium Trust definition (to allow Assemblies signed by your key to get Full Trust) or go back to putting Cassini into GAC, as in previous versions.
Thanks,
Dmitry