Archived

This topic is now archived and is closed to further replies.

rados

VB.net and VC.net

Recommended Posts

rados    127
I am trying to share source codes between Visual Basec .net and Visual C++ .net. So far I managed somehow to transfer VC code to VB but I CAN''T get the VB code to work in VC! If anyone knows how to do this please reply. P.S. I don''t want use DLL-s to do this...

Share this post


Link to post
Share on other sites
Arild Fines    968
You need to provide more information. You say VC++.NET and VB.NET - do you mean Managed C++ or native C++? If you want to expose VB.NET objects to unmanaged C++, you need to do it through COM by creating a CCW(COM Callable Wrapper) for your VB.NET assembly. When you register the object, you can use it from VC++ as any other COM object.
VB.NET to MC++ is easier - you don''t need the CCW since MC++ can easily reference managed assemblies with the #using directive.

quote:

P.S. I don''t want use DLL-s to do this...


That will be hard to avoid, since DLL''s are the fundamental piece of code reuse in both the COM and .NET environments.



The world holds two classes of men -- intelligent men without religion, and religious men without intelligence. - Abu''l-Ala-Al-Ma''arri (973-1057; Syrian poet)

Share this post


Link to post
Share on other sites
The_Trooper    122
I think he means that he wants to import code directly from VB to VC, like you can directly import a VC.Net class to VB.Net by "Add Reference" dialog. The problem is that there is no "Add Reference" in VC.Net.

Share this post


Link to post
Share on other sites
Arild Fines    968
Thats what the #using directive is for. Eg - #using "Assembly.Name.dll"



The world holds two classes of men -- intelligent men without religion, and religious men without intelligence. - Abu''l-Ala-Al-Ma''arri (973-1057; Syrian poet)

Share this post


Link to post
Share on other sites
alexmoura    450
Magmai, as far as I know you are absolutely correct - #using or add reference are referencing Dll''s, and more specifically >Net Dlls (they could be managed COM wrappers, but .Net Dll anyway).

You know, I never wanted to be a programmer...

Alexandre Moura

Share this post


Link to post
Share on other sites
thona    100
"Add Reference" does not load a dll. It makes a DLL availablee during compilation.

For native managed assemblies this means adding it to the compiler line.

For COM assemblies this means:
(a) generating a wrapper DLL and
(b) adding this to the compiler line.

What about reading documentation, folks? And having a look on how interop works on the command line - then you would understand this immediatly :-)


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post


Link to post
Share on other sites