2 projects same solution
my solution is set up:
Solution
| --vbProject
| |--References
| |--cppProject
| |--mscorlib
|--cppProject
| |--References
| |--vbProject
| |--mscorlib
i've also been playing around, keeping it simple
right now i get complier" error C2065 'objVB' : undeclared identifer"
my code is like this:
--
int cppClass::go(){ objVB *test;
}
-
and if i hover the mouse over objVB it says "__gc class vbProject::objVB" in a popup bubble. now should i have some type of "using vbProject" im a little new at this cross compiling with vb and c++ in the same solution....
im thinking im missing some includes/using/somthing?
[966 byte] By [
spids] at [2008-2-6]
Your problem is that you have a circular reference: vb references cpp references vb and so on. This is not allowed.
You can remove this circular reference by creating a new project and extracting all classes you want to share across multiple projects in there:
|-- vbProjectShared
|-- cppProjectShared
|-- vbProject
| |-- vbProjectShared
| |-- cppProjectShared
|-- cppProject
|-- vbProjectShared
|-- cppProjectShared
Thanks for the help. Too bad VS doesnt give warnings when you compile :S. I tried seperating the class from VB that i needed into it's own class to get around the circular reference but it's too tightly wound into the main program to seperate :S.
So now im just using it 1 sided. ie creating a C++ object in VB and calling functions.
only 1 problem everything comiples but as soon as C++ code try's to make a new object out of a class that is not "managed code" it throws a stack overflow error. but if i take that part out and just have a simple class managed class.
ie
--
System::String *myFunction(System::String *parm1, System::String *parm2){
....
return str;
}
it works. i can pass a string into my C++ function from VB and get it back on the return. then MsgBox it to screen.
but when i put in some includes and start to refference thing's outside my managed class
#include "unManaged.h"
System::String *myFunction(System::String *parm1, System::String *parm2){
unManaged *um = new unManaged(); // <here
....
return str;
}
-
as i step through and debug the program it dies right there with stack overflow
funny though i had issues using CStirng as well. in my managed class.
Anyone have a clue how i can use my unManaged class? it comiples just dies when the program is running

Hi,
There is one workaround to overcome the circular reference problem without changing anything. That is to actually not reference and instantiate classes at runtime dynamically.
You can go ahead and reference the VB dll from C++ but do not reference the C++ in VB.NET. Then use Type.GetTypeFromClsId to get the type of the C++ class if the C++ DLL is a COM DLL. And then pass the type as a parameter to Activator.CreateInstance and use the methods again using Reflection - this would have a performance overhead but it would work.
Regards,
Vikram
well my VB project is an exe and has an hundreds of thousands of lines of code. so the c++ project has to be refferenced from the VB. im a little confused on Activator.CreateInstance and how it relates to the issue of working with Managed and unManaged code in C++
could you clear that up a bit?
From the explanation above it looked like you have a issue of circular reference which u agreed to be having. In that case, you need to have a reference to the VB project from C++ and vice-versa? But I did not realize that your VB project was a a .EXE. There is no way u can use the suggestion I gave on an EXE - so it does not help.
As for Activator.CreateInstance that can be used to instantiate any dotnet type. And when u use Type.GetTypefromClsId, u can consume COM Objects as well with an automatic layer of COM Interop that .NET Provides.
Regards.
Vikram
well i did have that circular reference problem. but because i cannot make my "large" VB project into a seprate class that can be passed into C++, i gave up trying.
unless there is a way to take a "complex" class that depends on other class' in it's own project (IE the VB class') and pass just 1 instance to C++ by Reff or by complete object.
because my problem is:
1) I cannot seperate the VB class i want to pass from the project into another project because of dependencys
2) IF I dont seperate them i get a circular refference problem.
That is why i came to the conclusion just add a refference to the C++ project in the VB project and use it's functions. without passing the VB class into the C++ class.
everything works fine until the C++ trys to make an object out of a class that is included from a unmanaged header file. ( might i add ) the .cpp/.h files compile in the same C++ project. just when im running the VB app it dies when it trys to create the object.
error: "An unhandled exception of type 'System.StackOverflowException' occurred in hadbxcl.dll"