Calling C++ function from VB

D

Dan Hinsley

I want to be able to use a C style cast in a VB app. Now I understand
that you can't do that, but I also see how I can have routines written
in various languages be part of the same exe. I've done this as a
test with C#, but it appears to be just as restrictive as VB when it
comes to what I want to do. So the question is, is there a way to
write a C++ routine, and then link it with VB. I'd prefer to do this
with Visual Studio, but would do it via cmd line options if that were
the only way.

For the curious, what I want to do is write out an array of structures
into an Access DB as a BLOB, and then read it back in (as an array of
bytes) but then cast it to an arrays of structs so I can process it.

Any help would be greatly appreciated.

Dan Hinsley
(e-mail address removed)
 
H

Herfried K. Wagner [MVP]

* Dan Hinsley said:
I want to be able to use a C style cast in a VB app. Now I understand
that you can't do that, but I also see how I can have routines written
in various languages be part of the same exe. I've done this as a
test with C#, but it appears to be just as restrictive as VB when it
comes to what I want to do. So the question is, is there a way to
write a C++ routine, and then link it with VB. I'd prefer to do this
with Visual Studio, but would do it via cmd line options if that were
the only way.

That's not supported. You can use different programming languages for
different projects. Maybe these tools will fit your needs:

<URL:http://www.gotdotnet.com/community/usersamples/?query=illink>

<URL:http://research.microsoft.com/research/downloads/#ILMerge>
Documentation: <URL:http://research.microsoft.com/~mbarnett/ilmerge.aspx>
 
D

Dan Hinsley

B

Brian Henry

you can only compile files from the same language in each project (each
exe,dll made can only be one language) as of .net 1.1 (vs.net 2003), now in
VS 2005, you will be able to mix and compile different languages into the
same project (have C++,C#,VB) all in the same exe file since the compilers
are a lot smarter in the new version.
 
H

Herfried K. Wagner [MVP]

* Dan Hinsley said:
I know you can combine vb and cs files (since I've done that). Are
you saying that you can't combine vb and c++ files?

What do you mean by "combine"?

No, you can't combine pure unmanaged C++/C with .NET "files".
 

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