AutoCAD OPM扩展C#插件接口未实现却可编译的问题
AutoCAD 2024 OPM动态属性实现的编译问题
我正在给AutoCAD 2024的对象属性管理器(OPM)添加自定义属性,已参考相关技术文档并fork了OPMNetExt项目。适配AutoCAD 2024与ObjectARX 2024后,C++模块编译正常,但C#插件项目出现异常情况:明明提示“IDynamicProperty2接口成员未实现”,却能成功编译;若按照Visual Studio提示将接口方法的out参数改为ref,反而会编译失败。
C#中IDynamicProperty2的实现代码片段
[Guid("F60AE3DA-0373-4d24-82D2-B2646517ABCB"), ProgId("OPMNetSample.CustomProperty.1"), ClassInterface(ClassInterfaceType.None), ComDefaultInterface(typeof(IDynamicProperty2)), ComVisible(true)] public class CustomProp : IDynamicProperty2 { private IDynamicPropertyNotify2 m_pSink =null; void IDynamicProperty2.GetGUID(out Guid propGUID) { propGUID = new Guid("F60AE3DA-0373-4d24-82D2-B2646517ABCB"); } void IDynamicProperty2.GetDisplayName(out string szName) { szName = "My integer property"; } // 其他接口方法实现... }
C++中IDynamicProperty2的接口定义片段
[InteropServices::Guid("9CAF41C2-CA86-4ffb-B05A-AC43C424D076")] [InteropServices::InterfaceTypeAttribute(InteropServices::ComInterfaceType::InterfaceIsIUnknown)] [InteropServices::ComVisible(true)] public interface class IDynamicProperty2 { void GetGUID([InteropServices::Out] System::Guid% propGUID); void GetDisplayName([InteropServices::Out, InteropServices::MarshalAs(InteropServices::UnmanagedType::BStr)] interior_ptr<System::String^> name); // 其他接口方法定义... };
修改后编译失败的代码片段
void IDynamicProperty2.GetDisplayName(ref string szName) { szName = "My integer property"; }
内容的提问来源于stack exchange,提问作者Nick
相关产品推荐
相关产品推荐

