c# - MVC 2 和 .NET 4.0 的 AllowPartiallyTrustedCallersAttribute 错误

标签 c# asp.net asp.net-mvc security .net-4.0

Assembly 'Foo.BAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

我有一个调用我的数据访问层的标准业务层,为什么我在使用 MVC 2 和 .NET 4.0 时会收到此错误?

我之前使用的是 Enterprise Block,所以我放弃了它,现在只使用标准的 System.Data.SqlClient API 来最大限度地减少依赖性。

编辑:如果我将 BAL 和 DAL 项目上的目标框架更改为 3.5,我不会收到错误。

最佳答案

安全模型在 .NET 3.5 和 .NET 4 之间发生了相当大的变化。

http://msdn.microsoft.com/en-us/library/dd233103.aspx

关于c# - MVC 2 和 .NET 4.0 的 AllowPartiallyTrustedCallersAttribute 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3368254/

相关文章:

jquery - 什么时候通过 AJAX 提交表单比较好,什么时候通过服务器端提交比较好?

ASP.NET MVC 在哪里编写查询逻辑

javascript - 在 ASP.NET MVC View 页面中使用 C# 生成 javascript 是否正确?

c# - 如何使用 CacheManager 设置 Redis 服务器池大小?

c# - 简单的 3D AABB-Line Segment 碰撞检测(交叉点)

c# - Action 的通用约束没有按预期工作

c# - 将 WaitOne 与 IPC 命名互斥体一起使用时,可以有一个空的 while block 吗?

asp.net - 使用 BotDetect 验证码时为 "Object reference not set to an instance of an object."

asp.net - 负载平衡 Web 服务器上的 Orchard CMS

javascript - 是否可以将事件传递给 Ajax 表单的 OnBegin 函数?