- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 .Net 4.5.2 和 Entity Framework 6.1.3 创建了一个基本的 WCF 数据服务和 Entity Framework。数据库中只有一张表。
配置如下:
public class MyDataService : DataService<DataItemsDataContext>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
config.UseVerboseErrors = true;
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
config.SetEntitySetAccessRule("DataItem", EntitySetRights.All);
}
}
当我启动项目时,我可以看到:
网址:http://localhost:49570/MyDataService.svc/
内容:
<service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xml:base="http://localhost:49570/MyDataService.svc/">
<workspace>
<atom:title>Default</atom:title>
<collection href="DataItem">
<atom:title>DataItem</atom:title>
</collection>
</workspace>
</service>
当我选择表格时,出现以下异常:
网址:http://localhost:49570/MyDataService.svc/DataItem
内容:
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code/>
<m:message xml:lang="en-US">An error occurred while processing this request.</m:message>
<m:innererror>
<m:message>Operation could destabilize the runtime.</m:message>
<m:type>System.Security.VerificationException</m:type>
<m:stacktrace>
at: queryable_reader(Object )
at: System.Data.Services.Providers.ReflectionServiceProvider.GetQueryRootForResourceSet(ResourceSet container)
at: System.Data.Services.Providers.ReflectionDataServiceProvider.GetQueryRootForResourceSet(ResourceSet resourceSet)
at: System.Data.Services.Providers.DataServiceProviderWrapper.GetQueryRootForResourceSet(ResourceSetWrapper resourceSet)
at: System.Data.Services.RequestUriProcessor.ComposeExpressionForEntitySet(SegmentInfo segment, IDataService service, Boolean isLastSegment, Boolean checkRights)
at: System.Data.Services.RequestUriProcessor.ComposeExpressionForSegments(IList`1 segments, IDataService service, Boolean isCrossReferencingUri)
at: System.Data.Services.RequestUriProcessor.ProcessRequestUri(Uri absoluteRequestUri, IDataService service, Boolean internalQuery)
at: System.Data.Services.DataService`1.ProcessIncomingRequestUri()
at: System.Data.Services.DataService`1.HandleRequest()
</m:stacktrace>
</m:innererror>
</m:error>
可能是some .Net bug .
什么会导致这种情况?我应该改变什么?
最佳答案
看起来它确实是一个错误(或者至少是一个限制性功能)。
首先,我使用Entity Framework 6.1.3作为数据库ORM,出现错误。
当我切换回 Entity Framework 5.0 时,服务正常运行。
根据这个KB article :
Assume that you upgrade an earlier version of the .NET Framework to the .NET Framework 4.5 on a computer. When you use some third-party controls, you may receive a System.Security.VerificationException exception. This issue occurs if the following conditions are true:
- The third-party controls use the generic types.
- The CLR verifier is enabled by declaring an assembly that is marked as security-transparent.
我推测,EF 6.x 使用泛型类型,因此会导致问题。
解决方法是使用 Entity Framework 5.0。而不是 Entity Framework 6.x。
关于c# - WCF 数据服务的 VerificationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29809072/
每当我在附加调试器的情况下运行以下任一单元测试时,我都会在 FluentValidation 中得到一个 VerificationException此时的代码(如有必要,稍后将发布整个堆栈跟踪): a
我使用 .Net 4.5.2 和 Entity Framework 6.1.3 创建了一个基本的 WCF 数据服务和 Entity Framework。数据库中只有一张表。 配置如下: public
为什么此代码会抛出“System.Security.VerificationException:操作可能会破坏运行时的稳定性。”? MethodInfo mi = typeof(TypedRefere
我读过这个post我想使用 ControllerExtensions.RedirectToAction 方法。但是我有 System.Security.VerificationException 说:
我正在使用 IL 生成创建一个简单的反序列化器方法,该方法从 Lucene 文档中提取字符串并设置引用类型对象 (POCO) 的属性或字段。 每当我尝试运行生成的方法时,我都会收到 Verificat
我收到“操作可能会破坏运行时异常”。我瞪大了眼睛,看起来异常与在运行时加载的冲突程序集有关。所以,这里有几件事 相同的源代码在我同事的机器上运行。 我查看并搜索了对 NewtonSoft.Json.d
似乎当我使用 OpenCover 检测程序集时, 组件与 SecurityTransparent属性(似乎还有 AllowPartiallyTrustedCallers)将抛出 Verificatio
我正在制作一个声音合成程序,用户可以在其中通过基于节点的合成、创建振荡器、滤波器等来创建自己的声音。 程序将节点编译成中间语言,然后通过 ILGenerator 和 DynamicMethod 将其转
我需要在运行时使用 TypeBuilder 创建一个类型。这种类型应该实现一个特定的接口(interface),以便可以在编译时统一处理这种动态类型的实例。 该接口(interface)应返回一个对象
我正在将我的一个项目从 VS2008 迁移到 VS2010。现在,当我运行测试工具时,我将解决方案中的所有项目都转换为 .NET 4.0(客户端配置文件),几乎所有测试都失败了,但出现以下异常: Sy
帮帮我,为什么这段代码在 .NET 4.0 下运行时会导致 VerificationException? public T parseEnum(string value, T defaultValu
我正在使用 FluentValidation 3.4.6,我的项目的目标框架是 .net 4。我已经彻底检查了我的解决方案,以确保没有引用旧版本的 FluentValidation。 我相信这个版本的
在尝试重构 MVC 4 应用程序期间,我的代码出现了这样的扭曲,我从 Subversion 恢复了整个东西。但是,现在,当我运行代码时出现以下异常,并且无法弄清楚如何消除它。 Server Error
我想通过委托(delegate)调用某些方法,但得到了 VerificationException。我正在使用以下代码: internal delegate void Delegete_add
我遇到了 MVC3 RC 的奇怪行为。 我使用单元测试创建了默认的 Internet 应用程序,并且我的计算机上的所有单元测试都失败了。所有测试都有错误"System.Security.Verif
我正在开发一个 Android 应用程序,它使用我的 REST 后端。后端在 JBoss 实例上运行,该实例通过 Keycloak 进行保护。自从我将 Keycloak 从 1.0.7 更新到 2.1
我试图在事件发生时触发一个 Action ,忽略事件参数(至少现在)。我通过反射找到事件,然后创建一个匹配预期签名的动态方法(不能保证它只是发件人/EventArgs) 并从那里尝试调用该操作。 //
我有一个将构造函数包装在动态工厂方法中的方法: static Func ToFactoryMethod(this ConstructorInfo ctor) where TResult : c
我最近尝试将一个由 SubSonic 2.2 生成 DAL 的 .net 2.0 项目升级到 Visual Studio 2010 下的 .NET 4.0。 项目转换没有错误,但现在我在尝试启动它时收
我有类似的代码 using FluentValidation; public class FreeformValidator : AbstractValidator { public Free
我是一名优秀的程序员,十分优秀!