gpt4 book ai didi

vb.net - 实现属性必须具有匹配的 'ReadOnly' 或 'WriteOnly' 说明符

转载 作者:行者123 更新时间:2023-12-01 04:01:04 24 4
gpt4 key购买 nike

我在 idl 文件中定义了一个接口(interface),并尝试将 vb6 项目转换为 vb.net。

转换从此 idl 的 tlb 创建了互操作,并且在 vs2010 中它提示该属性未实现(如下所示)。有谁知道为什么?我什至删除了实现并让 vs2010 重新生成 stub ,但仍然出错。

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,它是 .声明在 WTypes.h SDK 头文件中给出,第 1025 行(对于 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 Set
End Property

关于vb.net - 实现属性必须具有匹配的 'ReadOnly' 或 'WriteOnly' 说明符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13467819/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com