  | | | Memebers property of Group | Memebers property of Group 2005-05-15 - By Brad Friedman
Back I've run into a bit of an oddity that I thought I'd point out. Perhaps someone can enlighten me. I've already worked around this problem so its not any kind of priority for me. I'm just currious. I hate letting oddities that I don't understand slip by.
I'm programming in c# through the dotNetFramework which has built in COM interoperability. So I imported the COM libraries and all has been well. Getting along quite well... until...
The "Memebers" property of the "Group" interface is returning a strange object that the early bound COM interop is having trouble with. It should be an object that implements the "SceneItemCollection" interface. And indeed, if I type cast to it, I don't get an exception. So the type cast appears valid. But if I then call anything on the object, I get an exception that says there's something wrong with the "query interface." When I look up information I find this to be sort of internal to COM. And I get muddled information on the net that says this is somewhat akin to an invalid type cast.
So I assumed the COM interop in dotNet was messing things up and moved on to working around it. I made an addon for myself to work with:
http://xsi.fie.us/fiejseval/
Using the addon, I have my c# code call the command and pass it some jscript code that gets the Members property and returns it as an object. Then in my c# code, I type cast it to a "SceneItemCollection." But when I run this code, I get a type cast exception. Apparently, this object is not of the type "SceneItemCollection". Yet, if I play with the object in jscript land, it appears to be a "SceneItemCollection" none the less. The addon works fine. I can pass any other object from the script back to c# and type cast it appropriately. Only the object I get from Group.Members acts this way.
Anyhow, my final workaround works fine. I just do all of my accessing of the Members property with jscript through my addon from c#. I return other objects from the API and type cast them to work with them in c#. No problems. Its just this one property on the Group interface thats acting this way.
Any thoughts? I'm kinda vexxed.
-brad --- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|
 |