473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2467
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stephen | last post by:
I have been getting on well with help from this forum trying to create an array list and work with it. Everything is working fine apart from displaying my array list items into the labels in my...
9
by: Lloyd Dupont | last post by:
Does any of you have the slightest ideas of why you can't modify an array list while in a foreach of its element. I wrote my own collection and I'm trying to add the same behavior but I don't...
1
by: Kevin P. Fleming | last post by:
ArrayList implements an overload for IEnumerator's GetEnumerator method as follows: GetEnumerator(int offset, int count) However, I can't see a way to take advantage of this, even though I'd...
1
by: Matthias S. | last post by:
Hi, I'm trying to provide the user of my class access to the objects in a collection without allowing him to modify (add/remove/clear items) the collection. I thought I can do it by providing a...
5
by: Keith O | last post by:
Assume fooList is an ArrayList foreach(string s in fooList) { if (some condition) { fooList.Remove(s); } } I get the following runtime error:
7
by: Steven | last post by:
I have 2 arraylists (name and value). Is there anyway that I can make that into one arraylist with 2 columns. First column as name and second column as value? -- Steven
18
by: Rob Panosh | last post by:
Hello, When traversing an ArrayList which is faster? For Each oItem as Something in me.ArrayList ..... ..... Next OR
5
by: toldyouso | last post by:
The following script works in IE but in Firefox errors with the msg Enumerator is not defined. <html> <head> <meta name="vs_defaultClientScript" content="JavaScript"> <script...
6
by: fniles | last post by:
I am using VB.NET 2003 and a socket control to receive and sending data to clients. As I receive data in 1 thread, I put it into an arraylist, and then I remove the data from arraylist and send it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.