VC++;6.0从COM DLL生成的.TLH导致错误 问题是,我在C .net中创建了一个DLL和TLB,使它可以被看到,并希望将函数暴露给MFC C++项目——我首先做了一个测试类,它工作正常,并且没有从C++生成的TLH中得到任何错误。现在,我要使用的实际DLL给了我以下编译错误: error C2059: syntax error : '<' error C2238: unexpected token(s) preceding ';' error C2059: syntax error : '<' error C2238: unexpected token(s) preceding ';' error C2059: syntax error : '<' error C2238: unexpected token(s) preceding ';' error C2059:syntax error:“

VC++;6.0从COM DLL生成的.TLH导致错误 问题是,我在C .net中创建了一个DLL和TLB,使它可以被看到,并希望将函数暴露给MFC C++项目——我首先做了一个测试类,它工作正常,并且没有从C++生成的TLH中得到任何错误。现在,我要使用的实际DLL给了我以下编译错误: error C2059: syntax error : '<' error C2238: unexpected token(s) preceding ';' error C2059: syntax error : '<' error C2238: unexpected token(s) preceding ';' error C2059: syntax error : '<' error C2238: unexpected token(s) preceding ';' error C2059:syntax error:“,c++,.net,dll,typelib,C++,.net,Dll,Typelib,这些字段是使用自动属性时由C#编译器生成的。比如: [ComVisible(true)] public class TagReadEvent { public long Index { get; set; } // etc... } 你应该回去修理C代码。还要使用接口并将类/结构保持为[ClassInterface(ClassInterfaceType.None)],这样就不会公开任何实现。这条路很好。如果不能,那么可以使用#import指令中的exclude属性跳过麻烦制造者

这些字段是使用自动属性时由C#编译器生成的。比如:

[ComVisible(true)]
public class TagReadEvent {
    public long Index { get; set; }
    // etc...
}
你应该回去修理C代码。还要使用接口并将类/结构保持为[ClassInterface(ClassInterfaceType.None)],这样就不会公开任何实现。这条路很好。如果不能,那么可以使用#import指令中的exclude属性跳过麻烦制造者。比如:

#import "something.dll" exclude("TagReadEvent")
重命名属性也可以修复它

#import "something.dll" exclude("TagReadEvent")