转换从这个IDl的tlb创建了interop,并且在vs2010中它抱怨该属性没有被实现(如下所示).有谁知道为什么?我甚至删除了实现并让vs2010重新生成存根,但仍然是错误.
IDl中的示例界面..
[ uuID(...),version(2.0),dual,nonextensible,oleautomation]interface IExampleInterface : Idispatch{ ... [ID(3),propget] HRESulT CloseDate ([out,retval] DATE* RetVal); [ID(3),propput] HRESulT CloseDate ([in] DATE* InVal);}
VB.Net类……
<System.Runtime.InteropServices.ProgID("Project1_NET.ClassExample")>Public Class ClassExample Implements libname.IExampleInterface Public Property CloseDate As Date Implements libname.IExampleInterface.CloseDate Get Return mDate End Get Set(value As Date) mDate = value End Set End Property解决方法 DATE参数类型是问题.它不是DateTime或Date,它是Double.该声明在WTypes.h SDK头文件中给出,第725行为v7.1:
typedef double DATE;
因此,通过将其声明为Double并根据需要来回转换来修复您的属性:
Public Property CloseDate As Double Implements libname.IExampleInterface.CloseDate Get Return mDate.ToOADate End Get Set(value As Date) mDate = DateTime.FromOADate(value) End SetEnd Property总结
以上是内存溢出为你收集整理的vb.net – 实现属性必须具有匹配的’ReadOnly’或’WriteOnly’说明符全部内容,希望文章能够帮你解决vb.net – 实现属性必须具有匹配的’ReadOnly’或’WriteOnly’说明符所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)