我已經使用實體框架6.1.3使用.Net 4.5.2創建了具有實體框架的基本WCF數據服務。在數據庫中只有一個表。VerificationException與WCF數據服務
下面是配置:
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。
這是什麼原因造成的?我應該改變什麼?
您是否已將此發送給Microsoft? http://connect.microsoft.com/VisualStudio。我很傷心自己碰到這個問題,不得不降級到EF 5。 – Aligned