473,326 Members | 2,061 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,326 software developers and data experts.

Consuming VB.NET DLL in VC++.NET


Hi,

I'm sure this is a question that comes up reasonably regularly, but I'm
getting an error with the forum search function at the moment, and haven't
found anything with a browse, so forgive me if this is repeating things!!

Should also clarify that it's a VERY long time since I've done much C++, so
I may well have forgotten something simple...

I have a VB.NET dll that I'd like to be able to use in a VC++.NET
application (all using VS.NET 2003). all the documentation I've found
suggests that all I need to do is to copy the DLL into an output folder and
tell the compiler to look in that folder to resolve #using directives, then
add a #using "VBFunctions.dll" into my cpp file.

Following that, I should be able to create an instance of this class and
happily use it. I've tried this with:

VBFunctions *oFunctions = new VBFunctions();

But I get a "VBFunctions : undeclared identifier" when trying to build the
solution.

Any help is gratefully received!

Thanks

Simon
Nov 23 '06 #1
6 1217
"Simon Smith" <Si********@discussions.microsoft.comwrote in message
news:A5**********************************@microsof t.com...
I have a VB.NET dll that I'd like to be able to use in a VC++.NET
application (all using VS.NET 2003). all the documentation I've found
suggests that all I need to do is to copy the DLL into an output folder
and
tell the compiler to look in that folder to resolve #using directives,
then
add a #using "VBFunctions.dll" into my cpp file.
Is your VC++ application native or managed - i.e. does it target Win32 or
..Net? A simple procedure such as you sketched should work in the latter
case.

If though, you have a Win32 caller and a .Net callee, there is more work to
do. I sketch a method for doing that here:

http://groups.google.com/group/micro...1afe6d2e0f0113

(My sample uses a C# callee but that doesn't matter)

Regards,
Will
Nov 23 '06 #2


"William DePalo [MVP VC++]" wrote:
"Simon Smith" <Si********@discussions.microsoft.comwrote in message
news:A5**********************************@microsof t.com...
I have a VB.NET dll that I'd like to be able to use in a VC++.NET
application (all using VS.NET 2003). all the documentation I've found
suggests that all I need to do is to copy the DLL into an output folder
and
tell the compiler to look in that folder to resolve #using directives,
then
add a #using "VBFunctions.dll" into my cpp file.

Is your VC++ application native or managed - i.e. does it target Win32 or
..Net? A simple procedure such as you sketched should work in the latter
case.

If though, you have a Win32 caller and a .Net callee, there is more work to
do. I sketch a method for doing that here:

http://groups.google.com/group/micro...1afe6d2e0f0113

(My sample uses a C# callee but that doesn't matter)

Regards,
Will

I was under the impression that the app was targeting .net, but it's a third
party project template that I'm not too familiar with. Given that just
importing the DLL hasn't worked, I'll try the interop services method you
have linked to; I'm out of other ideas, so why not!

Thanks for your help.

Si
>
Nov 23 '06 #3
OK. So I've done this and I now get a message "A namespace with this name
does not exist"

I've checked the registry after the regasm bits and pieces, and I've spelt
the namespace right in the cpp.

The only thing I couldn't do from your example was the [ClassInterface] bit;
I can't find any reference to this in VB.net
Nov 23 '06 #4
"Simon Smith" <Si********@discussions.microsoft.comwrote in message
news:B3**********************************@microsof t.com...
I was under the impression that the app was targeting .net, but it's a
third
party project template that I'm not too familiar with. Given that just
importing the DLL hasn't worked, I'll try the interop services method you
have linked to; I'm out of other ideas, so why not!
Well, the sample wo which I pointed to is for interoperating between the
Win32 and .Net platforms. If you are targetting .Net in the pieces written
in C++, my sample is beside the point.

If you are not sure what you have you can inspect the switches on the
compiler and linker command lines. If you are compiling with /clr and
linking against mscoree.lib than you are targetting .Net

Regards,
Will
Nov 24 '06 #5


"William DePalo [MVP VC++]" wrote:
"Simon Smith" <Si********@discussions.microsoft.comwrote in message
news:B3**********************************@microsof t.com...
I was under the impression that the app was targeting .net, but it's a
third
party project template that I'm not too familiar with. Given that just
importing the DLL hasn't worked, I'll try the interop services method you
have linked to; I'm out of other ideas, so why not!

Well, the sample wo which I pointed to is for interoperating between the
Win32 and .Net platforms. If you are targetting .Net in the pieces written
in C++, my sample is beside the point.

If you are not sure what you have you can inspect the switches on the
compiler and linker command lines. If you are compiling with /clr and
linking against mscoree.lib than you are targetting .Net

Regards,
Will
The C++ parts are targeting Win32, so the sample is valid. I still can't get
it to work, though. I've checked the registry and I'm using the correct class
names and files, but whatever I do I get a "undeclared identifier" error when
I try to reference anything using the class name.
Nov 24 '06 #6

"Simon Smith" <Si********@discussions.microsoft.comwrote in message
news:A5**********************************@microsof t.com...
>
Hi,

I'm sure this is a question that comes up reasonably regularly, but I'm
getting an error with the forum search function at the moment, and haven't
found anything with a browse, so forgive me if this is repeating things!!

Should also clarify that it's a VERY long time since I've done much C++,
so
I may well have forgotten something simple...

I have a VB.NET dll that I'd like to be able to use in a VC++.NET
application (all using VS.NET 2003). all the documentation I've found
suggests that all I need to do is to copy the DLL into an output folder
and
tell the compiler to look in that folder to resolve #using directives,
then
add a #using "VBFunctions.dll" into my cpp file.

Following that, I should be able to create an instance of this class and
happily use it. I've tried this with:

VBFunctions *oFunctions = new VBFunctions();

But I get a "VBFunctions : undeclared identifier" when trying to build the
solution.
You will also need a using namespace statement.

Get .NET Reflector (http://www.aisto.com/roeder/dotnet/) in order to find
out the exact names available inside your VB assembly.
>
Any help is gratefully received!

Thanks

Simon

Nov 24 '06 #7

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

Similar topics

0
by: vijay | last post by:
Hello Problem in short : VC++ code not able to identify .net interface ... during compile time giving compile errors I have written a .net component and add ed to GAC and registered and...
11
by: Tatu Portin | last post by:
Have this kind of struct: typedef struct { char **user_comments; /* ... */ } vorbis_comment; /* prototype */ char * read_vorbis_string ( FILE *sc);
0
by: vijay | last post by:
Hello Problem in short : VC++ code not able to identify .net interface ... during compile time giving compile errors I have written a .net component and add ed to GAC and registered and...
7
by: Roberto Perez via .NET 247 | last post by:
Hello all and thank you in advance. We have several old applications in Cobol, Centura, etc that needs to be converted to .NET In order to save time our plan is to create web services and call...
6
by: kbs | last post by:
Hi, I'm looking for some good examples that illustrate how to code a web service that exposes a custom collection so that the properties of the collection are accessible on the client without...
0
by: plmanikandan | last post by:
I need to develop a application to consume a webservice. For consuming web service i tried a example in Consuming a Web Service in C# in http://www.csharphelp.com.But i am uanble to use that...
1
by: Matyi | last post by:
Hello everybody! I've this problem: I'm working on a download meter, based on wpcap. As wpcap code is unmanaged, I decided to create the needed functions in a unmanaged project (one for...
2
by: eSapient | last post by:
I have a case where a C# dll is being consumed by an unmanaged C++ executable. One of the dll methods returns a StringCollection object. What are the requirements for the C++ executable in terms of...
9
by: Kadett | last post by:
Hi all, I have following problem: I'm creating a ListView (Details) control at run-time and filling it with some records (let's say 10 000). This operation seems to be quite fast, but when I call...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.