[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

problem in InvalidCastException-Return argument has an invalid type

John

6/29/2004 7:46:00 PM

Hi,
I have my client application call a method in a remote object hosted in IIS.
The return value is a typed dataset. The problem that I have is the method
call works fine in server side, but once the return value returns to client
side, it throws exception: "An unhandled exception of type
'System.InvalidCastException' occurred in mscorlib.dll Additional
information: Return argument has an invalid type."
System.InvalidCastException: Return argument has an invalid type.
at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg,
Type paramType)
at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage
msg, Object[] outArgs, Object returnValue)
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)

Has anyone have similiar problem before? I appreciate any response very
much.


2 Answers

sprungli

6/29/2004 8:56:00 PM

0

Hi John,

I have the same problem and already posted a similar question in this
newsgroup, but got no answer so far. The DataSet I am trying to return is
untyped but the exception message is the same. Unfortunately I haven''t any
clue on why this happens. DataSets can be sent across the network, so I
don''t know what to think. If you come across a possible solution or at least
a reason for this behavior, please post to the newsgroup; so will do I.



Good luck!


"John" <l_zhou@hotmail.com> wrote in message
news:O3%23QrGhXEHA.2940@TK2MSFTNGP09.phx.gbl...
> Hi,
> I have my client application call a method in a remote object hosted in
IIS.
> The return value is a typed dataset. The problem that I have is the method
> call works fine in server side, but once the return value returns to
client
> side, it throws exception: "An unhandled exception of type
> ''System.InvalidCastException'' occurred in mscorlib.dll Additional
> information: Return argument has an invalid type."
> System.InvalidCastException: Return argument has an invalid type.
> at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg,
> Type paramType)
> at
System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage
> msg, Object[] outArgs, Object returnValue)
> at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
> reqMsg, IMessage retMsg)
> at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
> msgData, Int32 type)
>
> Has anyone have similiar problem before? I appreciate any response very
> much.
>
>


Sunny

6/30/2004 2:45:00 PM

0

Hi,

DataSet is always serialized to XML. It does not depend on what formater
you are using for remoting. Actually I haven''t any problems with this so
far, but I have seen some people reporting this problem, and in most
cases the problem was that the auto generated class for the typed
DataSet is not shared between the client and server.

SO, try this:

1. Put the xsd and autogenerated .cs file in a separate assembly and
reference it both from the server and the client. In runtime, make sure
that this assembly is accessible both from the server and client (I.e.
there is a copy of it in the corresponding folders). This should solve
the problem.

2. If for some reason the above does not help, as I said DataSets are
always serialized to XML, so you can just use WriteXml to serialize it
in your remote method and return the XML string, and then recreate it
back at the client.

Sunny


In article <O3#QrGhXEHA.2940@TK2MSFTNGP09.phx.gbl>, l_zhou@hotmail.com
says...
> Hi,
> I have my client application call a method in a remote object hosted in IIS.
> The return value is a typed dataset. The problem that I have is the method
> call works fine in server side, but once the return value returns to client
> side, it throws exception: "An unhandled exception of type
> ''System.InvalidCastException'' occurred in mscorlib.dll Additional
> information: Return argument has an invalid type."
> System.InvalidCastException: Return argument has an invalid type.
> at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg,
> Type paramType)
> at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage
> msg, Object[] outArgs, Object returnValue)
> at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
> reqMsg, IMessage retMsg)
> at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
> msgData, Int32 type)
>
> Has anyone have similiar problem before? I appreciate any response very
> much.
>
>
>