How to make a Dictionary<> visible to vbscript

A

Andrew Falanga

Hi,

I hope this is the right forum. How do I make a Dictionary object in
C# visible, and usable, to VBScript? Should I ask this in a VBScript
forum, or this one?

Andy
 
H

Harlan Messinger

Andrew said:
Hi,

I hope this is the right forum. How do I make a Dictionary object in
C# visible, and usable, to VBScript? Should I ask this in a VBScript
forum, or this one?

Objects exist in methods, routines, processes, and they are either
visible or not visible to other methods, routines, processes. The
concept of an object being either visible or not visible to a *language*
is invalid.

What are you running in C# and where are you running it, and what are
you running in VBScript and where are you running it? Are you running an
C# ASP.NET application on a web server, with the C# application running
on the server and sending web content to a browser, including code in
VBScript that runs in the browser? Are you trying to run a website with
some ASP.NET pages written in C# but also with some ASP pages with
server-side code written in VBScript?
 
J

Jeff Johnson

I hope this is the right forum. How do I make a Dictionary object in
C# visible, and usable, to VBScript? Should I ask this in a VBScript
forum, or this one?

In order for anything .NET to be visible to VBScript it will need to be
COM-visible. I don't exactly know how to do that, but I know that's the
route you need to go.
 
A

Andrew Falanga

Objects exist in methods, routines, processes, and they are either
visible or not visible to other methods, routines, processes. The
concept of an object being either visible or not visible to a *language*
is invalid.

What are you running in C# and where are you running it, and what are
you running in VBScript and where are you running it? Are you running an
C# ASP.NET application on a web server, with the C# application running
on the server and sending web content to a browser, including code in
VBScript that runs in the browser? Are you trying to run a website with
some ASP.NET pages written in C# but also with some ASP pages with
server-side code written in VBScript?

Thank you for the education I really am quite ignorant about these
things.

I'm not working with a web implementation of anything. There is no
ASP.NET. So far as I know, it's simply .NET. I have to make certain
things in my C# sources ComVisible, but that's about it. I'm
wondering how I could iterate over a Dictionary<> object, produced in
a method in my C# code, that is returned by that COM visible method
when that method is called by a VBScript; e.g. use in a Foreach (or
whatever it is VBS calls it). I have no problems returning boolean,
int or strings but I figured it's because VBScript new about such
types, or at the least, that they were primitive types in .NET.
However, I was unsure of the Dictionary<> object.

Andy
 
J

Jesse Houwing

* Andrew Falanga wrote, On 4-11-2009 23:45:
Thank you for the education I really am quite ignorant about these
things.

I'm not working with a web implementation of anything. There is no
ASP.NET. So far as I know, it's simply .NET. I have to make certain
things in my C# sources ComVisible, but that's about it. I'm
wondering how I could iterate over a Dictionary<> object, produced in
a method in my C# code, that is returned by that COM visible method
when that method is called by a VBScript; e.g. use in a Foreach (or
whatever it is VBS calls it). I have no problems returning boolean,
int or strings but I figured it's because VBScript new about such
types, or at the least, that they were primitive types in .NET.
However, I was unsure of the Dictionary<> object.


VBScript does not understand Generic classes. But most generic
interfaces also implement their non generic counterpart. So you should
be able to use that in VBScript.

So either return a non-generic Dictionary, or create your own dictionary
class that implements both IDictionary<T> and IDictionary.

Use the IDictionary<T> in C# and fall back to IDictionary in VBScript.
 
A

Andrew Falanga

* Andrew Falanga wrote, On 4-11-2009 23:45:






VBScript does not understand Generic classes. But most generic
interfaces also implement their non generic counterpart. So you should
be able to use that in VBScript.

So either return a non-generic Dictionary, or create your own dictionary
class that implements both IDictionary<T> and IDictionary.

Use the IDictionary<T> in C# and fall back to IDictionary in VBScript.

Thanks. Sounds like I've got some reading to do. I figured out that
the dictionary isn't what I need, but rather a List. I'm assuming I'd
use the same approach. Is this true?

Andy
 
J

Jesse Houwing

* Andrew Falanga wrote, On 5-11-2009 1:23:
Thanks. Sounds like I've got some reading to do. I figured out that
the dictionary isn't what I need, but rather a List. I'm assuming I'd
use the same approach. Is this true?

Correct. Make sure you implement both or inherit from IList<T>.
 

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

Top