VB to .NET

Upgrading Interfaces declared in an ActiveX Library

This is related to upgrading Groups of Projects, but in this case the ActiveX library is upgraded through Interop, which differs from a native upgrading. One of the differences is that properties with arguments ByRef are converted to methods with the prefixes “get_” and “set_”. This implies that the VB6 AI Migrator must convert this kind of properties to methods too when upgrading through Interop.

There is a consideration for this feature when upgrading to Visual Basic .NET. If these properties were converted to methods, there would not be a way to get a target code that can be compiled correctly. Writing the same implementing class from the beginning in the Visual Studio editor is not possible either, so this seems to be an issue with Interop upgrading in Visual Studio. The issue consists on the generation of that property. The Interop generation converts that property to a set property with a ByRef argument, but in Visual Basic .NET this is not allowed.

Original VB6 code

Library::AnInterface.cls

Public Property Get p1() As String
End Property
Public Property Let p1(v As String)
End Property

Project::AClass.cls

Implements Library.AnInterface
Public Property Get AnInterface_p1() As String
End Property
Public Property Let AnInterface_p1(v As String)
End Property


VB6 AI Migrator resulting VB.NET code

Implements Library.AnInterface
    Public Property p1() As String Implements InterfacesToInterop.AnInterface.p1
        Get

        End Get
        Set(ByVal value As String)

        End Set
    End Property


VB6 AI Migrator resulting C#.NET code

internal class AClass
    : InterfacesToInterop.AnInterface{
                  public string get_p1()
                  {
                      return String.Empty;
                  }
        public void set_p1(ref string v)
                  {
                  }
    }

 

Talk To An Engineer