Warning when using an Assembly in C++ that was built in C#
I have an assembly that I'm building using C# and an application that I'm developing in C++ that uses the assembly. I have both of these projects in the same solution. Everything was working fine but recently when I build the C++ applications I've begun to get the warning listed below. I get this warning for every object I've defined in the C# assembly. Any suggestions would be appreciated
Warning 1 warning C4945: 'PositionEstimator' : cannot import symbol from 'c:\documents and settings\douglas havenhill\my documents\visual studio 2005\projects\controlpointlibrary\controlpointlibrary\obj\debug\controlpointlibrary.dll': as 'Doppler::ControlPointLibrary::PositionEstimator' has already been imported from another assembly 'ControlPointLibrary' c:\documents and settings\douglas havenhill\my documents\visual studio 2005\projects\controlpointlibrary\controlpointlibrary\obj\debug\controlpointlibrary.dll 1
Doug Havenhill
[958 byte] By [
dough1a] at [2007-12-26]
I am having the same problem that the original poster stated; however, my case is different than this, and perhaps this instance of the problem is a bug. If it is not a bug, it seems like it should be prevented by the pragma "once"
Here's a simplified version of my circumstances. I am using Visual Studio 2005, and a mix of C++ /clr with C#.
I have an assembly written in C# called "Common" for purposes of discussion, I will call this assembly C#Common. Then I have two C++ /clr assemblies, I'll call them C++A and C++B
In C++A is
using C#Common
In C++B is
using C#Common
using C++A
When I compile C++B, I get C4945 on the symbols that are defined in C#Common, and it seems to me that this should not happen.
If I remove, as the link you posted for the compiler warning suggests, C#Common from C++A, C++A simply will not build. Also, if I remove C#Common from from C++B, C++B simply will not build. Likewise, since C++B is dependent on C++A, removing C++A from C++B is not an option.
It is as if C++B is importing C#Common from C++A; however, it seems like this should not be happening. So, what I am seeing seems completely unrelated to the case where there are two different assemblies defining the same symbol as in the link you posted, because, in fact, there is only one assembly, C#Common, where the symbols are defined.
Any suggestions would be appreciated.
Thank you.
Best Regards,
Matthew
OK. Seems I found a solution that works.
In "references" for C++B, I was referencing C#Common, and in stdafx.h from C++B, I had "using namespace C#Common." Removing C#Common from the references for C++B but not from stdafx.h seems to have fixed the "problem."
Thanks.