Multiple Projects

Y

yossis

I have a .Net solution that contains multiple projects of both Managed
C++ and C#.

There are references in one Managed C++ project's classes to classes in
another Managed C++ project.
i.e. Proj2::Class2 uses Proj1::Class1

Proj2 has a reference entry for Proj1

Each projects uses its own namespace, so Proj2::Class2.cpp has a #using
namespace line referring to the namespace declared in the Proj1 classes

I cannot get this scenario to compile. I get:
"error C2512: 'Proj1::Class1' : no appropriate default constructor
available"

If I add #include "Class1.h" to Class2.cpp, then I alse get this:
"error C2011: 'ManagedCppProj1::Class1' : 'class' type
redefinition"

I have tried the same scenario in a dummy solution with 2 simple
Managed C++ projects and get the same results.

Both projects are mixed mode and reference common unmanaged static C++
libraries

Any ideas??
 
B

Bruno van Dooren

I could reproduce this with a test application and a control class.

the problem is that your reference (the dll or exe) contains an
implementation of your imported class, and the header file you include
contains another.

removing the reference from your project, or removing the header file
include statement solves this, because then only 1 implementation is found.

kind regards,
Bruno.
 
J

John Sun

yossis said:
I have a .Net solution that contains multiple projects of both Managed
C++ and C#.

There are references in one Managed C++ project's classes to classes in
another Managed C++ project.
i.e. Proj2::Class2 uses Proj1::Class1

Proj2 has a reference entry for Proj1

Each projects uses its own namespace, so Proj2::Class2.cpp has a #using
namespace line referring to the namespace declared in the Proj1 classes

I cannot get this scenario to compile. I get:
"error C2512: 'Proj1::Class1' : no appropriate default constructor
available"
[ I think this error message is pretty clear what you need to do, either
define a default constructor, or instantiate an instance with
properly defined constructor.]
If I add #include "Class1.h" to Class2.cpp, then I alse get this:
"error C2011: 'ManagedCppProj1::Class1' : 'class' type
redefinition"
[ I don't think you need to change to this, if you get a class not
defined error, then you may try this. The previous error message is damn
clear what you need to do to fix this issue].
 
Y

yossis

Thanks,

I only added the header file as an atttempt ot fix the problem. There
was only a reference entry originally which was producing the compiler
error (C2512) regarding default constructors. There is still a problem.
 
Y

yossis

If only it was that simple. There is a default constructor - the
problem seems to lie with the metadata imported through the reference
entry - possibly the unmanaged aspects that are linked into both
projects
 

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