开发者

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜