Ben
Ben

Reputation: 137

vs2008 Including Managed C++ class from one dll in another Managed C++ class?

I have a project called ManagedWrapper that is Managed C++ and builds as a DLL.

I have a second project called MyManagedTest that is Managed C++ and builds as a DLL.

When I try to include a header from ManagedWrapper in MyManagedTest, I get linker LNK2020 errors. I then add a reference to ManagedWrapper in "Frameworks and References" but this causes compiler errors saying that classes in ManagedWrapper are already defined (looks like it is trying to define them again in MyManagedTest because I included header files), error C2011.

What is the proper way to include classes from ManagedWrapper into MyManagedTest?

Thanks.

Upvotes: 2

Views: 423

Answers (1)

Ben Voigt
Ben Voigt

Reputation: 283793

You should use #include for native class declarations and #import for managed class declarations. Adding a reference is the same as #import.

BTW, "Managed C++" is not the correct name for using C++ with .NET in VS2008. That feature is C++/CLI. Earlier versions of Visual C++ had a very buggy syntax called "Managed Extensions for C++" which was often referred to as "Managed C++" and should never be used.

Upvotes: 1

Related Questions