4

I have an interface defined in an idl file and trying to convert a vb6 project to vb.net.

The conversion created the interop from the tlb of this idl and in vs2010 it complains about the property not being implemented (as shown below). Does anyone have any idea why? I even deleted the implementation and got vs2010 to regenerate the stub and still it errors.

example interface in the 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 class...

<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
johv
  • 4,424
  • 3
  • 26
  • 42
lee23
  • 409
  • 1
  • 3
  • 10

1 Answers1

2

The DATE argument type is the problem. It is not a DateTime or Date, it is a Double. The declaration is given in the WTypes.h SDK header file, line# 1025 for v7.1:

 typedef double DATE;

So fix your property by declaring it As Double and convert back and forth as needed:

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
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536