ArrayList as Enumerator in JScript

J

Jayme Pechan

I migrated a formerly C++ COM component to C# and I have been able to
duplicate all the old behavior except for one.

I have an enumeration property that returns a list of com objects. Using
the ArrayList to hold the com objects ought to work. If I add strings to
the ArrayList and return the list, the JScript enumerator object works great
to enumerate through all the strings but for some reason when I put com
objects in the array list instead, it doesn't work properly. What happens
is that the JScript can get a pointer to the object but the typeof(obj)
returns "unknown" instead of "object" like it normally would. This makes it
so that the JScript can't use the objects in the list. If I return one of
these objects directly from a property in the class instead of in the list,
JScript properly recognizes it as an object. The Current property in
IEnumerator returns a type "object" and the test property in my class also
returns "object". I'm not really sure what the enumator is doing to the
object.

Is there some trick or something I need to do to make this work correctly?
Since it works fine for strings, I would think it ought to work for com
objects as well. Thanks.

Jayme
 
W

Willy Denoyette [MVP]

|I migrated a formerly C++ COM component to C# and I have been able to
| duplicate all the old behavior except for one.
|
| I have an enumeration property that returns a list of com objects. Using
| the ArrayList to hold the com objects ought to work. If I add strings to
| the ArrayList and return the list, the JScript enumerator object works
great
| to enumerate through all the strings but for some reason when I put com
| objects in the array list instead, it doesn't work properly. What happens
| is that the JScript can get a pointer to the object but the typeof(obj)
| returns "unknown" instead of "object" like it normally would. This makes
it
| so that the JScript can't use the objects in the list. If I return one of
| these objects directly from a property in the class instead of in the
list,
| JScript properly recognizes it as an object. The Current property in
| IEnumerator returns a type "object" and the test property in my class also
| returns "object". I'm not really sure what the enumator is doing to the
| object.
|
| Is there some trick or something I need to do to make this work correctly?
| Since it works fine for strings, I would think it ought to work for com
| objects as well. Thanks.
|
| Jayme
|
|

You might get better answers when posting to the interop NG -
microsoft.public.dotnet.framework.interop
Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top