Hi,
I am coding in C# and working with COM objects that were
written in Java. The product documentation for the Java
stuff states that the MS JVM does not support interface
inheritance - and then the documentation goes on to give
VB6 examples of how to get to a base interface given a
child interface.
Well I need to get to the base interface in C#! I have an
interface called "IPersistentObj ect" and it has a base
interface of "ISysObject ". How can I get to ISysObject
given an instance of IPersistentObje ct? My code below
compiles but it's not working {pardon the spacing but the
newsgroup dooesn't do source code too well}:
{
IPersistentObje ct pobj = CreatePersisten tObject();
ISysObject sysObj = (ISysObject)
Marshal.GetType dObjectForIUnkn own
(Marshal.GetIUn knownForObject( pobj), typeof(ISysObje ct));
IntPtr punk = Marshal.GetIUnk nownForObject(s ysObj);
sysObj.setObjec tName("MyObject ");
}
When this code runs "punk" reveals a non-zero value which
I'm taking to mean that in fact the QueryInterface did
succeed; the sysObj is an RCW that referes to something
that supports IUnknown. However when I try to use the
interface, to call "setObjectName" , I get a
System.NullRefe rence exception. Any ideas?
--Richard
I am coding in C# and working with COM objects that were
written in Java. The product documentation for the Java
stuff states that the MS JVM does not support interface
inheritance - and then the documentation goes on to give
VB6 examples of how to get to a base interface given a
child interface.
Well I need to get to the base interface in C#! I have an
interface called "IPersistentObj ect" and it has a base
interface of "ISysObject ". How can I get to ISysObject
given an instance of IPersistentObje ct? My code below
compiles but it's not working {pardon the spacing but the
newsgroup dooesn't do source code too well}:
{
IPersistentObje ct pobj = CreatePersisten tObject();
ISysObject sysObj = (ISysObject)
Marshal.GetType dObjectForIUnkn own
(Marshal.GetIUn knownForObject( pobj), typeof(ISysObje ct));
IntPtr punk = Marshal.GetIUnk nownForObject(s ysObj);
sysObj.setObjec tName("MyObject ");
}
When this code runs "punk" reveals a non-zero value which
I'm taking to mean that in fact the QueryInterface did
succeed; the sysObj is an RCW that referes to something
that supports IUnknown. However when I try to use the
interface, to call "setObjectName" , I get a
System.NullRefe rence exception. Any ideas?
--Richard
Comment