I have a legacy COM-component with an interface declaring a property like this (IDL notation):
interface IPasswordCallback : IUnknown { [propget] HRESULT Password( [in] VARIANT_BOOL ownerNeeded, [in, out] VARIANT_BOOL* isResultValid, [out, retval] BSTR* password ); }
This interface is implemented in a calling application written in VB6 like this:
Public Property Get IPasswordCallback_Password(ByVal ownerNeeded As Boolean, ByRef isResultValid As Boolean) As String 'implementation cut End Property
Everyting works fine until I try to do the same in VB.Net. VB.Net refuses to compile code where a parameter of a property is passed ByRef. MSDN says VB.Net doesn’t allow such parameters.
Is there any way I could implement such a property in VB.Net?
Create a new interface around the old interface that has the property properly implemented. You don’t need the original source you can just reference it from VB6 and make a new ActiveX DLL/OCX to do the job. A bit of pain to do I realize.
I ran into this myself on my conversion project and had to go back to the old VB6 code and make sure all the property parameters were declared ByVal. The problem was that we had to wait for a major version change in the VB6 code (when we break binary compatibility). Doing makes the new DLL not compatible with the old DLL.