Remote object method call to return another remote object

Remote object method call to return another remote object

Post by Scott Pric » Sun, 12 Jan 2003 08:33:12



I am receiving a System.InvalidCastException with a
message of 'Return argument has an invalid type'

When running code from the client I can successfully
create an instance of Class1 on the server, however when I
make the method call GetClass2 I get the above error.  I
want both of these to be CAO's because they have state
that pertains to the server machine.  Is it possible for a
CAO to have a method that can return a reference to
another CAO that needs to be created by the first CAO?  Am
I making any sense here?

Class1 : Inherits MarshalByRefObject
   Public Function GetClassTwo() As Class2
      Dim oRetVal As Class2 = New Class2()
      Return oRetVal
   End Function
End Class1

Class2 : Inherits MarshalByRefObject
   'Properties
   '...

   'Methods
   '...
End Class1