Click to See Complete Forum and Search --> : Wrapping unmanaged C++


Arthur
November 24th, 2004, 03:54 AM
Hello,

I have a huge set of unmanaged C++ classes, which I wrapped in managed C++.
Everything is in one assembly.
Using my wrapper in C# works fine.
However, when I would like to use the wrapper in managed C++ I get the
following warnings and errors:

warning C4945: 'MyType' : cannot import symbol from 'mydll.dll': as
'MyNamespace::MyType' has already been imported from another assembly
'mydll.dll'
stdafx.cpp(0) : see declaration of 'MyNamespace::MyType' first seen type is
used; re-order imported assemblies to use the current type

(Is this caused by forward declarations?)

And:

error C3635: 'MyUnmanagedNamespace::MyUnmanagedType': undefined native type
used in 'MyNamespace::MyType'; imported native types must be defined in the
importing source code
did you forget to include a header file?

My questions:

How can I solve these problems WITHOUT having to include my unmanaged header
files in the project that uses my assembly? I am not using any unmanaged
stuff, so why would I like to include anything?
I want to re-use the code at binary level only.

Greets,
Arthur

darwen
November 25th, 2004, 10:26 AM
How are you trying to reference your dll ?

Have you tried


#using "name of dll.dll"


instead of adding it to the references list ?

Darwen.

Arthur
November 25th, 2004, 10:55 AM
I do both...

The only solution I can think of is to dump all of the header files of my unmanaged library in "uncludeallunmanaged.h", and link the lib of the unmanaged library with my project. I don't want to let the users of this managed dll think about what unmanaged stuff they need to include...

Spy Hunter
December 3rd, 2004, 07:23 PM
Doing both is your problem. You need to do only one or the other. If you put the dll in your references and also put a #using statement, it tries to import the dll twice. (it's different than in C#)