I have an Entity Framework data model. Part of the model is the Customer object. The web service provides a method for retrieving a client and retrieving an updated version of that client for retention.
To test this, I created a new ASP.NET web application, (Solution> Add> New Project> ASP.NET Web Application), and then added a link to my service link using the standard Add Service Reference dialog. Then I call the service using the following code:
var client = new CustomerServiceClient();
var customer = client.GetCustomerByID(18);
customer.LimitDown = 100;
client.SaveCustomer(customer);
Everything works as expected.
Now I am doing the same thing, but this time with the ASP.NET website (Solution> Add> New Website> ASP.NET Website). I add the link in the same way and copy and paste the code above into the new site. But now I get the following exception, indicated on the 4th line:
System.InvalidOperationException EntityReference cannot be serialized. This type of object cannot be serialized when the RelationshipManager refers to an object of an object that does not implement IEntityWithRelationships.
Source Error:
Line 2474: Line 2475:
public SkyWalkerCustomerService.OperationResult SaveCustomer (SkyWalkerCustomerService.Customer client) {Line 2476:
return base.Channel.SaveCustomer (customer); Line 2477:} Line 2478:}
Stack trace:
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage( reqMsg, IMessage retMsg) +9475203
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData & msgData, Int32) +345
SkyWalkerCustomerService.ICustomerService.SaveCustomer( ) +0
SkyWalkerCustomerService.CustomerServiceClient.SaveCustomer( ) C:\Windows\Microsoft.NET\Framework\v4.0.30128\Temporary ASP.NET \testsite2\dd2bcf8d\f95604ff\App_WebReferences.fz4h7x7l.0.cs: 2476 _Default.Page_Load ( , EventArgs e) C:\Users\Mike\Documents\\\SkyWalker\TestSite2\Default.aspx.cs: 17 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback( , EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +61 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1966
. ?
, - -, , , .