New Posts New Posts RSS Feed: InvokeServerMethodAsync
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

InvokeServerMethodAsync

 Post Reply Post Reply
Author
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Topic: InvokeServerMethodAsync
    Posted: 27-Jun-2011 at 7:19pm
I have a RPC that I call which passes up an entity.  On the server, the code looks like this:
[AllowRpc]
public static object Test1(IPrincipal pPrincipal, EntityManager pPm, params Object[] pArgs)
{
Customer cust = (Customer)pArgs[0];
cust.ContactName = "Peter Pan";
pPm.SaveChanges{new [] cust });

return cust;

}
On the line where Peter Pan is assigned to the ContactName, an error of Object Ref not set to an instance of an object error is thrown. 
 
If I add a line which attaches it to the pPm, it no longer throws an error.  This would be fine, except in some instances, there are related items already attached to the entity. In this case, when it gets to the line which attaches the entity, it throws an error, saying that the related entity is already attached to the Entity Manager.  It doesn't make any sense to me why the main entity would not be attached, and the related entity would be attached.  Before the RPC call is made, the entity is attached to an EntityManager and saved, so it seems like it should already be attached.  The related entities are also saved and attached so it seems like they should come accross the wire in the same entity state as the cust.
 
I have been unable to resolve this issue.
Greg
Back to Top
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2011 at 1:24pm
Don't worry about this, I got it resolved. 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down