G
Guest
I have a .net framework 2.0 client (Pocket PC) and a .net 2.0 webservice that
communicate on the same LAN. The Pocket PC has no problem consuming strings
returned from the web service methoeds but I’m unable to receive and a custom
object. The error occurs when the PocketPC app casts a returned object
(WebServiceServer.objectA) from the webservice to pocketPC.ObjectA (results
in InvalidCastExeption). ObjectA is a simple class and is identical on the
PocketPC and Webservice. I’ve verified the object is being returned to the
PocketPC intact (debugging indicates all correct types exist and values
populated) but when I try to cast it from type Object to pocketPC.ObjectA in
the PocketPC code I get the exception. I’ve also replaced the representation
of pocketPC.ObjectA in Reference.cs with a copy of the actual
pocketPC.ObjectA. What am I doing wrong? Is this not supported by compact
framework?
Thanks,
Jim
public class ObjectA //same on client and web service
{
private string sStringA = string.Empty;
private string sStringB = string.Empty;
private string sStringC = string.Empty;
public ObjectA() { }
public ObjectA() string sParamA, DateTime dtParamB,string sParamC)
{
this.sStringA = sSomeStringDeterminedByWebServiceBizLogic;
this.sStringB = sSomeStringDeterminedByWebServiceBizLogic;;
this.sStringC = sSomeStringDeterminedByWebServiceBizLogic;;
}
public string StringA
{
get { return this.sStringA;}
set { this.sStringA = value; }
}
public string StringB
{
get { return this.sStringB; }
}
public string SringC
{
get { return this.sStringC; }
set { this.sStringC = value; }
}
}
Client code (Pocket PC)
public static ObjectA GetObjectAFromWebService()
{
WebServiceServer.Service ws = new WebServiceServer.Service();
object tmpObject = (object)ws.GetObjectAForPocketPC(someParamA,
someParamB);
ObjectA objectA = (ObjectA)tmpObject;
//The above cast results in the InvalidCastException
//I’ve also tried to assign directly to the PocketPC ObjectA but receive a
compile time error. The below statement does not work.
// ObjectA objectA = ws.GetObjectAForPocketPC (someParamA, someParamB)
return objectA;
}
communicate on the same LAN. The Pocket PC has no problem consuming strings
returned from the web service methoeds but I’m unable to receive and a custom
object. The error occurs when the PocketPC app casts a returned object
(WebServiceServer.objectA) from the webservice to pocketPC.ObjectA (results
in InvalidCastExeption). ObjectA is a simple class and is identical on the
PocketPC and Webservice. I’ve verified the object is being returned to the
PocketPC intact (debugging indicates all correct types exist and values
populated) but when I try to cast it from type Object to pocketPC.ObjectA in
the PocketPC code I get the exception. I’ve also replaced the representation
of pocketPC.ObjectA in Reference.cs with a copy of the actual
pocketPC.ObjectA. What am I doing wrong? Is this not supported by compact
framework?
Thanks,
Jim
public class ObjectA //same on client and web service
{
private string sStringA = string.Empty;
private string sStringB = string.Empty;
private string sStringC = string.Empty;
public ObjectA() { }
public ObjectA() string sParamA, DateTime dtParamB,string sParamC)
{
this.sStringA = sSomeStringDeterminedByWebServiceBizLogic;
this.sStringB = sSomeStringDeterminedByWebServiceBizLogic;;
this.sStringC = sSomeStringDeterminedByWebServiceBizLogic;;
}
public string StringA
{
get { return this.sStringA;}
set { this.sStringA = value; }
}
public string StringB
{
get { return this.sStringB; }
}
public string SringC
{
get { return this.sStringC; }
set { this.sStringC = value; }
}
}
Client code (Pocket PC)
public static ObjectA GetObjectAFromWebService()
{
WebServiceServer.Service ws = new WebServiceServer.Service();
object tmpObject = (object)ws.GetObjectAForPocketPC(someParamA,
someParamB);
ObjectA objectA = (ObjectA)tmpObject;
//The above cast results in the InvalidCastException
//I’ve also tried to assign directly to the PocketPC ObjectA but receive a
compile time error. The below statement does not work.
// ObjectA objectA = ws.GetObjectAForPocketPC (someParamA, someParamB)
return objectA;
}