Improved ActivexEXE migration

On version 3.0 the ActiveX DLLs and Activex EXE are converted using a helper class. This helper class uses application domains to manage the ActiveX behavior.

Activex EXE on version 4.0 are converted using a helper class. But in this case the helper class uses exe process instead of application domains to manage the ActiveX behavior. With this change the converted application is closer to functional equivalence with its original VB6 application.

ActiveX DLL are still converted using applications domains.

VB6 Code: (Activex EXE)

File: class1.cls
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
   ...
END
Attribute VB_Name = "Class1"
Attribute VB_Creatable = True
...
Public Sub ModifyGlobalVar( ByVal newValue As String)
    strValue = newValue
End Sub

File: Module1.bas
Attribute VB_Name = "Module1"
Public strValue As String

.NET Code: (Activex EXE)

File: class1.cs
using Artinsoft.VB6.Activex; 
...
public class Class1: Artinsoft.VB6.Activex.ComponentClassHelper
{
    public void  ModifyGlobalVar( string newValue)
    {
         Module1.strValue = newValue;
    }
}

File: Module1.cs
internal static class Module1
{
     public static string strValue = String.Empty;

     internal static void  InitGlobalVars()
    {
          strValue = String.Empty;
     }
}

VB6 Code: (Client code)

File: frmTest.vb
...
Private Sub cmdCreateInstances_Click()
    Obj1 = New myActiveXEXEMultiUse_GlobalVar.Class1
...    
End Sub

Private Sub cmdGet1_Click()
    txtValue1.Text = Obj1.ObtainValue()
    MsgBox("Global Var: " + Obj1.ObtainGlobalVar)
End Sub

Private Sub cmdSet1_Click()
    Obj1.ModifyValue(txtValue1.Text)
    Obj1.ModifyGlobalVar("Modified by Instance#1")
End Sub

Private Sub Form_Unload(ByVal Cancel As Integer)
    Obj1 = Nothing
End Sub

.NET Code: (Client code)

...
private void  cmdCreateInstances_Click( Object eventSender,  EventArgs eventArgs)
{
    Obj1 = yActiveXEXEMultiUse_GlobalVar.myActiveXEXEMultiUse_GlobalVarFactory.          
               Create<myActiveXEXEMultiUse_GlobalVar.Class1>(Obj1);
    ...                
}
            
private void  cmdGet1_Click( Object eventSender,  EventArgs eventArgs)
{
    txtValue1.Text = Obj1.ObtainValue().ToString();
    MessageBox.Show("Global Var: " + Obj1.ObtainGlobalVar(),
                              Application.ProductName);
}
            
private void  cmdSet1_Click( Object eventSender,  EventArgs eventArgs)
{
    Obj1.ModifyValue(Convert.ToInt32(Double.Parse(txtValue1.Text)));
    Obj1.ModifyGlobalVar("Modified by Instance#1");
}
            
private void  frmTest_Closed( Object eventSender,  EventArgs eventArgs)
{
    Obj1 = myActiveXEXEMultiUse_GlobalVar.myActiveXEXEMultiUse_
    GlobalVarFactory.Dispose<myActiveXEXEMultiUse_GlobalVar.Class1>(Obj1);
}