When this optional feature is enabled, the Visual Basic Upgrade Companion will generate attributes for the COM-exposed classes and their members, in order to keep the resulting assemblies exposed through a COM interface. This enables the resulting components to be called from other non-managed components via COM.
This feature is not available in the Upgrade Wizard, which means this backwards-compatibility feature must be manually implemented if needed.
In the example below, the original VB6 source code was contained in an ActiveX dll.
Public Sub method1() MsgBox “Hello world” End Sub
The Visual Basic Upgrade Companion generated source code will include some attributes to expose the resulting assemblies through a COM interface.
Option Strict Off Option Explicit On Imports System Imports System.Runtime.InteropServices Imports System.Windows.Forms <ComVisible(True)> <ProgId("Project1.Class1")> <ClassInterface(ClassInterfaceType.AutoDual)>
Public Class Class1 Public Sub method1() MessageBox.Show("hello world", Application.ProductName) End Sub End Class
using System; using System.Runtime.InteropServices; using System.Windows.Forms; using VB6 = Microsoft.VisualBasic.Compatibility.VB6.Support;
namespace Project1{
Generated attributes for COM visibility [ComVisible(true)] [ProgId("Project1.Class1")] [ClassInterface(ClassInterfaceType.AutoDual)]
public class Class1{
public void method1(){ MessageBox.Show("hello world", Application.ProductName); }}
}
Call us today at 1-425-609-8458 or email us at info@mobilize.net
8834 N Capital of Texas Hwy, Ste 302
Austin, TX 78759
Call us: +1 (425) 609-8458
info@wearegap.com