【问题标题】:WCF Data Service throws “Operation could destabilize the runtime” ExceptionWCF 数据服务抛出“操作可能破坏运行时”异常
【发布时间】:2015-02-12 23:26:25
【问题描述】:

我的目标是通过 IIS 将 SQL Server 2008 表公开为 XML/JSON。

我跟随 few(1) videos(2) 建立了一个 WCF 数据服务 Web 应用程序,当 $metadata 页面工作时,尝试查看实际数据会导致异常:

Operation could destabilize the runtime.
System.Security.VerificationException

Screenshots

我从这个 VS2013 template 开始,使用 .NET 4.5.1 和 Entity Framework 6.1.2 - 下面是更具体的包版本。

如果 NuGet 包导致 VerificationException,我是否应该尝试删除所有 NuGet 包,并仅添加 EntityFramework(以及任何依赖项)?

感谢任何想法,谢谢大家!

Id                             Version              Description/Release Notes                                                                                              
--                             -------              -------------------------                                                                                              
Antlr                          3.5.0.2              ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, in...
bootstrap                      3.3.2                Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.                 
EntityFramework                6.1.2                Entity Framework is Microsoft's recommended data access technology for new applications.                               
jQuery                         2.1.3                jQuery is a new kind of JavaScript Library....                                                                         
jQuery.Validation              1.13.1               This jQuery plugin makes simple clientside form validation trivial, while offering lots of option for customization....
Microsoft.AspNet.Mvc           5.2.3                This package contains the runtime assemblies for ASP.NET MVC. ASP.NET MVC gives you a powerful, patterns-based way t...
Microsoft.AspNet.Razor         3.2.3                This package contains the runtime assemblies for ASP.NET Web Pages. ASP.NET Web Pages and the new Razor syntax provi...
Microsoft.AspNet.Web.Optimi... 1.1.3                ASP.NET Optimization introduces a way to bundle and optimize CSS and JavaScript files.                                 
Microsoft.AspNet.WebPages      3.2.3                This package contains core runtime assemblies shared between ASP.NET MVC and ASP.NET Web Pages.                        
Microsoft.Data.Edm             5.6.3                Classes to represent, construct, parse, serialize and validate entity data models. Targets .NET 4.0, Silverlight 4. ...
Microsoft.Data.OData           5.6.3                Classes to serialize, deserialize and validate OData payloads. Enables construction of OData producers and consumers...
Microsoft.Data.Services        5.6.3                Fully-featured server API for responding to OData queries and consuming/producing OData payloads. Supports OData v3....
Microsoft.Data.Services.Client 5.6.3                LINQ-enabled client API for issuing OData queries and consuming OData payloads. Supports OData v3. Targets .NET 4.0,...
Microsoft.jQuery.Unobtrusiv... 3.2.3                jQuery plugin that unobtrusively sets up jQuery.Validation.                                                            
Microsoft.Web.Infrastructure   1.0.0.0              This package contains the Microsoft.Web.Infrastructure assembly that lets you dynamically register HTTP modules at r...
Modernizr                      2.8.3                Modernizr adds classes to the <html> element which allow you to target specific browser functionality in your styles...
Newtonsoft.Json                6.0.8                Json.NET is a popular high-performance JSON framework for .NET                                                         
Respond                        1.4.2                The goal of this script is to provide a fast and lightweight (3kb minified / 1kb gzipped) script to enable responsiv...
System.Spatial                 5.6.3                Contains classes and methods that facilitate geography and geometry spatial operations. Targets .NET 4.0, Silverligh...
WebGrease                      1.6.0                Web Grease is a suite of tools for optimizing javascript, css files and images.                                        

【问题讨论】:

    标签: .net asp.net-mvc entity-framework wcf wcf-data-services


    【解决方案1】:

    我安装了相同的软件包和更新,但我遇到了同样的错误。 我是这样解决的:

    1.按照该页面上的指南安装最新的 Nuget 包 Microsoft.OData.EntityFrameworkProvider;

    2.将 DataService 替换为 EntityFrameworkDataService,例如在您的 WcfDataService1.svc 中:

    公共类 WcfDataService1:EntityFrameworkDataService

    但是我不知道这是否是最好的做法,因为一些 ms 教程没有提及 EntityFrameworkDataService

    其他人这样做: http://blogs.msdn.com/b/odatateam/archive/2013/10/02/using-wcf-data-services-5-6-0-with-entity-framework-6.aspx

    http://blogs.msdn.com/b/odatateam/archive/2014/08/18/wcf-data-services-entity-framework-provider-is-updated-with-wcf-data-service-5-6-2.aspx

    【讨论】:

    • 感谢这最终成为最接近的答案。如果这有助于节省时间:使用 EntityFrameworkDataService 对象需要将此行添加到 using 块: using System.Data.Services.Providers;
    【解决方案2】:

    我经历了一个痛苦的过程,用 [DataServiceKey("ID")] 和许多其他选项装饰我的所有 POCO。这根本没有必要。只需从 EntityFrameworkDataService 而不是 DataService 继承您的服务。我知道 Visual Studio 模板将其添加为 DataService。所以请执行以下操作,它将解决问题:

    public class QueryServices : EntityFrameworkDataService<MathContext>
    

    【讨论】:

      【解决方案3】:

      我们在工作场所遇到了同样的问题。原因是在构造函数中使用了 lambda 表达式。安装这个解决了问题 kb2748645

      【讨论】:

      • 感谢您的发布,我尝试了您的链接,但由于某种原因安装被阻止。 imgur.com/8X8YgCm
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-22
      • 2012-11-05
      • 1970-01-01
      • 2014-12-01
      相关资源
      最近更新 更多