问题
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.
- I create the WCF Service Application,
- add references System.Data.Services
- Generate the EF Model
- Changed the Code Generation Strategy to "Default" and deleted the ".tt"
- Inherit the DataService< DBEntities> to my service class (Service1)
- Add the required "InitilizeService" routine
- 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