开发者

Visual C++ compile error C2871 - <namespace> : a namespace with this name does not exist

开发者 https://www.devze.com 2023-03-17 23:38 出处:网络
I am trying to create a ManagedWrapper dll that can be called from an MFC application that will not be compiled using /clr switch. In a header of my test MFC, I have declared the following:

I am trying to create a ManagedWrapper dll that can be called from an MFC application that will not be compiled using /clr switch. In a header of my test MFC, I have declared the following:

#import "ManagedProxy.tlb"
using namespace ManagedProxy;

When I try to compile the test MFC application, I get error C2871: 'ManagedProxy' : a namespace with this name does not exist. I am sure this has worked as recently as yesterday. If I specify a wrong tlb file name, I get compile error C1083, which indicates to me that the tlb file is being loaded correctly.

Why is Visual Studio now complaining and why did it work before?

Addition:

I just found out that my proxy stopped working after I changed the namespace to ManagedProxy. I have recompiled the Managed project, and the native application has as an Additional Include Path, the Debug folder of the managed project, so it should be referencing the latest tlb but it is not. I tried an absolute path to the tlb, cleaned and rebuilt project开发者_如何学JAVA with no luck.

Why is the tlb not the namespace change?

Addition Used Object Browser to see what is in TLB and the namespace ManagedProxy is somehow renamed to something else. I am also missing a couple of interfaces although they are marked with ComVisible(true).

Someone please help....

TIA.


You can rename the namespace when you import.

#import "ManagedProxy.tlb" rename_namespace("ManagedProxy")


The interfaces not showing up are likely not marked public.

0

精彩评论

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

关注公众号