473,804 Members | 3,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# calling .dll and returning VBA.CollectionC lass

Hello all and Happy New Year,

I've been having this problem for some time and thought I'd try to see
if anyone else out there has had the same problem or can give a little
help.

I'm using a website written in C# to call a .dll which in turn returns
a load of information. Most of this information is readable. However,
some of the information returned is of type VBA.CollectionC lass.

I've found from Microsoft that .NET cannot understand these types of
collections and only VB6 can read them.

If the collection is a simple collection then I can get the information
out by casting. However, if the information isn't basic then the
information returned isn't readable.

Has anyone encountered this problem? I'm sure someone out there must
be calling dll's which return VBA.CollectionC lasses...

Does anyone know whether the next version of .Net will be able to cope
with this?

Any help would be very much appreciated.

Ieuan Roberts

Nov 16 '05 #1
6 5512
Ieuan,

.NET can use the CollectionClass from VBA. You just have to set a
reference to MSVBVM60.dll (I believe that is it, it is in your system32
directory), and then look for it in the VBA namespace. You will find it
under the COM tab (you use it through COM interop) in the references dialog.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Ieuan" <ie************ *@hotmail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Hello all and Happy New Year,

I've been having this problem for some time and thought I'd try to see
if anyone else out there has had the same problem or can give a little
help.

I'm using a website written in C# to call a .dll which in turn returns
a load of information. Most of this information is readable. However,
some of the information returned is of type VBA.CollectionC lass.

I've found from Microsoft that .NET cannot understand these types of
collections and only VB6 can read them.

If the collection is a simple collection then I can get the information
out by casting. However, if the information isn't basic then the
information returned isn't readable.

Has anyone encountered this problem? I'm sure someone out there must
be calling dll's which return VBA.CollectionC lasses...

Does anyone know whether the next version of .Net will be able to cope
with this?

Any help would be very much appreciated.

Ieuan Roberts

Nov 16 '05 #2
Nicholas,

Thanks for the reply.

I've put in a reference to the dll you mentioned - this brings in a few
things into the references area including the VBA one you mention.

I then try to cast a VBA.CollectionC lass passed back from my dll into a
VBA.Collection. This works correctly but only so far as it shows the
converted object I'm trying to look at as an object of type
VBA.CollectionC lass and I can't get any further into the object. I'm
looking at this through the locals window.

If the object is a simple one dimensional array then I can manage a
foreach object in VBACollection and put the object into an arraylist.

However, I don't know what type most objects are - they could be an
array, an array of an array etc...
Any other suggestions would be most welcommed.

Ieuan

Nov 16 '05 #3
Ieuan,

The reason for this is that you need to cast it to the interface that
exposes the functionality. VB6 mucked around with COM, exposing interfaces
and trying to pass them off as classes. It's the kind of thing that causes
this mess in the first place.

Look for an interface named _Collection in the VBA namespace, and cast
to an instance of that. You should be able to access all the functionality
that you need once your CollectionClass is cast to that.

CollectionClass is a managed wrapper created by when you add the
reference which you can use to create the class instance (since you can't
create an interface).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ieuan" <ie************ *@hotmail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Nicholas,

Thanks for the reply.

I've put in a reference to the dll you mentioned - this brings in a few
things into the references area including the VBA one you mention.

I then try to cast a VBA.CollectionC lass passed back from my dll into a
VBA.Collection. This works correctly but only so far as it shows the
converted object I'm trying to look at as an object of type
VBA.CollectionC lass and I can't get any further into the object. I'm
looking at this through the locals window.

If the object is a simple one dimensional array then I can manage a
foreach object in VBACollection and put the object into an arraylist.

However, I don't know what type most objects are - they could be an
array, an array of an array etc...
Any other suggestions would be most welcommed.

Ieuan

Nov 16 '05 #4
Ieuan,

In addition to Nicholas, did you try to set a reference to
Microsoft.Visua lBasic and than use the collection in that. This would in my
opinion be compatible with the VBA collection. The Microsoft.Visua lBasic
namespace is a full part of the Framework.

I never tried it, just an idea.

Cor
Nov 16 '05 #5
Nicholas,

Thanks for your reply again.

I tried what you suggested and had no luck.

My code looks similar to this - where ciObj is the whole thing being
returned from the dll and Fields_Names being the VBA.Collection I'm
interested in:
VBA.Collection col1 = (VBA.Collection ) ciObj.Fields_Na mes;
VBA._Collection col2 = (VBA._Collectio n) ciObj.Fields_Na mes;
VBA.CollectionC lass col3 = (VBA.Collection Class) ciObj.Fields_Na mes;

Under all 3 of these castings, looking through the locals window, the
values for col1, col2 and col3 are displayed with a value of
{VBA.Collection Class} and you can't dig down into the actual dataa held
within that class.

Any further suggestions would be most welcommed.

Ieuan

P.S.
I mentionned in my earlier mail that providing the collection held a
basic array I could read it. I do this by:
ArrayList arTemp = new ArrayList();
foreach (object obj in VBA.Collection)
{
arTemp.Add(obj. ToString());
}

This works for array's as the object comes through as a string.

However, on a more complex collection, the object comes through a
{System.__ComOb ject} and I can do nothing with this.

Nov 16 '05 #6
Nicholas,

Thanks for your reply again.

I tried what you suggested and had no luck.

My code looks similar to this - where ciObj is the whole thing being
returned from the dll and Fields_Names being the VBA.Collection I'm
interested in:
VBA.Collection col1 = (VBA.Collection ) ciObj.Fields_Na mes;
VBA._Collection col2 = (VBA._Collectio n) ciObj.Fields_Na mes;
VBA.CollectionC lass col3 = (VBA.Collection Class) ciObj.Fields_Na mes;

Under all 3 of these castings, looking through the locals window, the
values for col1, col2 and col3 are displayed with a value of
{VBA.Collection Class} and you can't dig down into the actual dataa held
within that class.

Any further suggestions would be most welcommed.

Ieuan

P.S.
I mentionned in my earlier mail that providing the collection held a
basic array I could read it. I do this by:
ArrayList arTemp = new ArrayList();
foreach (object obj in VBA.Collection)
{
arTemp.Add(obj. ToString());
}

This works for array's as the object comes through as a string.

However, on a more complex collection, the object comes through a
{System.__ComOb ject} and I can do nothing with this.

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1840
by: Andrew Slade | last post by:
Hello, I am making calls from one compilation unit to functions in another by pointers and I get the warnings below from gcc on 2.4.x Debian Linux. The executable seems to work fine but the warnings bothers me a lot, mostly because I don't understand what I did wrong. The code I used I got from the FAQ on the matter, question 4.12. "warning: passing arg 2 of `hash_emumerate' from incompatible pointer type" "warning: passing arg 2...
8
2637
by: elizabeth | last post by:
New to .NET and writing a C# ASP.Net application that needs to access a COM+ VB dll (which I was not involved in writing). The COM+ VB dll returns a VB Collection. I use VBA.CollectionClass to define my return object. Everything works great but the question is (coming from a C++ person): what exactly is this VBA.Collection? Is it going to slow down the app. when we are in production? Would it better faster to add a method to the COM+...
7
2031
by: JJ | last post by:
Hi, I call a class in my windows service app and in that class I access a method that returns an OleDbReader. Now It does have records in the reader when I step through the method but when I return to calling class the OleDbReader dr is null. What am I missing here? Class1 calls Class2.Method which returns a OleDbReader. Class1's OleDbReader is null.
4
1062
by: Bernie Yaeger | last post by:
I'd like to run an external exe before returning to the calling app. For example: System.Diagnostics.Process.Start("f:\imcapps\xbuild\xbuild.exe") When I call this, the code beneath immediately runs, but I don't want it to begin running until xbuild.exe does its stuff. Any way I can do this, other than an extensive for loop beneath this to delay its effect? Thanks for any help.
3
9106
by: Mike | last post by:
Timeout Calling Web Service I am calling a .NET 1.1 web service from an aspx page. The web service can take several minutes to complete its tasks before returning a message to the aspx page. If the web service is taking a long time to complete, the aspx page returns a ‘The operation has timed-out.’ Message to the web browser after 100 seconds. I’ve added: <httpRuntime executionTimeout="300" /> to the web.config files
2
3153
by: Geler | last post by:
A theoretical question: Sorry if its a beginner question. Here is a quote from the MSDN explaning the C/C++ calling convention.. It demonstrates that the calling function is responsible to clean the stack pointer and it does it by the command "add esp,8" after returning from the called function. My questions: 1. Is the stack pointer common in a certain thread(or process)? 2. How does the called function get the parameters, is it by...
3
3584
by: Opa | last post by:
Hi , I have a form with javasript which launches a popup via the showModalDialog() method. I get the dialog to open, now I am trying to first get a reference to the calling form from the popup and then do a refresh of the calling form. Any ideas on how to get a reference to the calling form? I tried window.parent.location.reload() , but it doesn't work. Thanks a lot.
0
1209
by: saheli | last post by:
In my C# project i call a VB 6.0 .dll which in turn returns a load of information. Most of this information is readable. However, some of the information returned is of type VBA.CollectionClass. Actually the VB function returns collection of collection. (A colection that in turn stores many collection objects). I am able to get back the Collection returned from VB but is unable to get the values from the collection that is present in...
13
7824
by: Steve | last post by:
On page 392 of "Javascript the definitive guide" a function is called like this:- <form action="processform.cgi" onsubmit="return validateForm();"> Why, in this instance, is the return statement used in calling the function validateForm rather than being included inside the function? Thanks in advance,
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10327
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.