Re: problem in InvalidCastException-Return argument has an invalid type

From: Sunny (sunnyask_at_icebergwireless.com)
Date: 06/30/04


Date: Wed, 30 Jun 2004 09:45:00 -0500

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.
>
>
>



Relevant Pages

  • Re: how to export view to display - xml with specific xsd?
    ... Also xp_cmdshell runs on the server, ... SQL Server to a file and open the file in Word on the client machine. ... It opens up a ... XML to be generated in a Word-specific XML format. ...
    (microsoft.public.sqlserver.xml)
  • Re: XML->Dataset->Database
    ... latest configuration information and the server contains completed survey ... special database tables to control the flow of information, and using XML ... based on what needs to be sent to the client, ...
    (microsoft.public.dotnet.general)
  • Re: Arch question.
    ... If you do create seperate xml classes just for webservices ... ' NameInfo and get result as type HelloResult ... >> 1) On the server, I have my server classes that don't consider any xml. ... >> 4) The client has copy of xmldoc classes as needed. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: porting Access to SQL Server --- what to do with the front-end?
    ... They are both server side languages. ... As you state, HTMl, CSS, and javascript on the client ... Requests to the server use HTTP requests which send either URL-encoded ... strings or XML documents. ...
    (comp.databases.ms-access)
  • Re: DataSet and serialization is dangerous
    ... The dataset deserialization is based on XML. ... perl client, etc. ... Your server can only depend on the ... The client could have deleted/added Father1 a 100 ...
    (microsoft.public.dotnet.framework.adonet)