Why am i having problems with EF5 with WCF Service Application?

江枫思渺然 提交于 2019-12-11 18:28:57

问题


I have created EF Data Services before but I'm receiving this message everytime I try and create a EF5 - WCF Service Application.

The operation 'ProcessRequestForMessage' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.

  1. I create the WCF Service Application,
  2. add references System.Data.Services
  3. Generate the EF Model
  4. Changed the Code Generation Strategy to "Default" and deleted the ".tt"
  5. Inherit the DataService< DBEntities> to my service class (Service1)
  6. Add the required "InitilizeService" routine
  7. No changes to web.config

When i try and debug I get the message. I am using VS2012

It was a while ago since i've used Data Services but looking at my old VS2010 project that works I have modified web.config to include a service with an endpoint with "System.Data.Services.IRequestHandler" as the contract.

I also tried it again aswell as changing the binding to a "webHttpBinding" That didn't seem to work either. Any ideas?

If all else fails i guess i can use Open Access ORM with its built in service generation tools because I can atleast get that working.

Best Regards

Chris Leach


回答1:


Add: Factory="System.Data.Services.DataServiceHostFactory, Microsoft.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"




回答2:


I had the same error but I noticed that "Factory" attribute is missing in my service host markup file. So, click on your Data Service file and select "View Markup" and check is there Factory attribute and it is correct:

Before:

<%@ ServiceHost Language="C#" Debug="true" 
    Service="ServiceNamespace.ServiceClassName"    
    CodeBehind="ServiceClassName.svc.cs" %>

After:

<%@ ServiceHost Language="C#" Debug="true" 
    Service="ServiceNamespace.ServiceClassName"
    Factory="System.ServiceModel.Activation.WebServiceHostFactory, System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"      
    CodeBehind="ServiceClassName.svc.cs" %>



回答3:


Didn't figure this out directly however I downloaded the Demo Project from this website http://code.msdn.microsoft.com/windowsdesktop/WCF-Data-50-for-OData-v3-53074189 and modified the Data service then Voala. No more errors

Hope this helps others

Cheers for trying guys.



来源:https://stackoverflow.com/questions/12674237/why-am-i-having-problems-with-ef5-with-wcf-service-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!