#77 Any ctor with object ref and TypeCode throws BAD_PARAM

v1.0 (example)
open
nobody
5
2007-10-26
2007-10-26
Chris Arnold
No

Tested against 1.9.0.final (IIOPChannel 1.9.1.0)

The org.omg.CORBA.Any(object, TypeCode) constructor will always throw a BAD_PARAM (minor code 454) when the target object is a remote reference. The remarks in Any.cs don't suggest that this shouldn't be possible. The single argument constructor works OK, so this is probably not a significant problem.

TypeCode.cs line 201 [TypeCodeImpl.IsInstanceOfTypeCode(object val)] reads:
return GetClsForTypeCode() == val.GetType();

When constructing an any containing an ObjRef, the full error message (from attached test case) is:

CORBA system exception : omg.org.CORBA.BAD_PARAM [The given instance IIOPObjRefTest.Server of type System.MarshalByRefObject, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is not compatible with the type code of kind tk_objref mapped to type ObjRefTest, test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null] , completed: Completed_MayBe minor: 456

My implementation is probably not the most efficient, nor is it completely tested, but as a suggestion, the following will allow the Any to be successfully constructed (and subsequently marshaled with no problems):

if (System.Runtime.Remoting.RemotingServices.IsTransparentProxy(val)) {
return omg.org.CORBA.OrbServices.GetSingleton().is_a(val,this.id());
} else {
return GetClsForTypeCode().IsAssignableFrom(val.GetType());
}

Discussion


  • Chris Arnold
    2007-10-26

    Simple any constructor test case

     
    Attachments