Print Page | Close Window

InvokeServerMethodAsync

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2801
Printed Date: 16-Apr-2026 at 12:34pm


Topic: InvokeServerMethodAsync
Posted By: gregweb
Subject: InvokeServerMethodAsync
Date 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



Replies:
Posted By: gregweb
Date Posted: 28-Jun-2011 at 1:24pm
Don't worry about this, I got it resolved. 



Print Page | Close Window