MarshalByRef problem

jonx1

New member
Joined
Jan 21, 2003
Messages
1
Hope someone can help me on this one. I have an SAO, which includes a method that returns a marshalByRefObject. The server compiles without a hitch. I then run soapsuds against it to get the client interface dll. On the client side I can get the SAO object, no problem and can access methods on it that return regular value types. However when I invoke the method that returns the additional marshalByRefObject I get the exception below.

Now I know that if I was returning an object by value Id have to create a generic.dll containing the value type so both the server and client can see it then run soapsuds with the -gc option but in this case Im using marshalByRefs only so this shouldnt apply, right?

Ive also included the code Im using below.

Id appreciate any tips you can give me on this.

-Jon.

System.InvalidCastException: Return argument has an invalid type.
at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg, Ty
pe paramType)
at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage
msg, Object[] outArgs, Object returnValue)
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
at PortfolioServer.PortfolioManager.getRealPortfolio() in c:\documents and se
ttings\jmeadows\my documents\visual studio projects\portfolioclient\portfolioser
ver.cs:line 18
at PortfolioClient.Client.Main(String[] args) in c:\documents and settings\jm
eadows\my documents\visual studio projects\portfolioclient\class1.cs:line 40

Client:

...
HttpChannel cn = new HttpChannel();
ChannelServices.RegisterChannel( cn );

PortfolioManager mgr = (PortfolioManager) Activator.GetObject(
typeof( PortfolioManager),
"http://localhost:1410/PortfolioManager.soap" );

//This works fine, just returning a string from the remote obj.
String aString = mgr.getAString();

//This works less well.
Portfolio aPortfolio = mgr.getPortfolio();
...

Server:

...
public class PortfolioManager: MarshalByRefObject
{

static void Main( String args[] )
{
HttpChannel cn = new HttpChannel( 1410 );
ChannelServices.RegisterChannel( cn );

RemotingConfiguration.RegisterWellKnownServiceType(
typeof( PortfolioManager ),
"PortfolioManager.soap",
WellKnownObjectMode.Singleton);
}

public Portfolio getPortfolio( String userid )
{
return new Portfolio();
}

}


public class Portfolio: MarshalByRefObject
{
private String tester;

public String getTester()
{
return tester;
}

}
...
 
If you are getting an InvalidCastException, can you not break in that function and see what exactly the type is that you are getting back?
 
Back
Top