471,089 Members | 1,175 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

ArrayList as Enumerator in JScript

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
Aug 19 '06 #1
2 2375
How can you have so many things about JScript than C#?
Anyway hope this is what you are looking.See how they loop through with
IEnumerable.

http://msdn2.microsoft.com/en-us/lib...arraylist.aspx
chanmm

"Jayme Pechan" <ja**********@whitefeld.comwrote in message
news:OT**************@TK2MSFTNGP04.phx.gbl...
>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

Aug 20 '06 #2
"Jayme Pechan" <ja**********@whitefeld.comwrote in message
news:OT**************@TK2MSFTNGP04.phx.gbl...

|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.
Aug 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Lloyd Dupont | last post: by
1 post views Thread by Kevin P. Fleming | last post: by
5 posts views Thread by Keith O | last post: by
7 posts views Thread by Steven | last post: by
5 posts views Thread by toldyouso | last post: by
6 posts views Thread by fniles | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.