ISSUE #7013

    Constructor is just executed once. Please review if Component contains SingleUse classes because they have a different behavior

    This in a NOTE EWI. That means the migration tool has perfomed some automated changed but there is different behavior. In this case the tool has upgraded an ActiveX DLL or ActiveX EXE where there was a Start up object set to the main method of a module.

    See ActiveX Dll topic page or ActiveX EXE topic page for some background on ActiveX technologies and the VBUC migration options.

    When this happens the migration tool introduces some code to make sure that the main method is invoked when a class is instantiated. 

    Your migrate class will have a static constructor added. A static constructor is used because in .NET static constructor are only called once per process. That static constructor will then call a static method. That static method reference will trigger the static constructor on the module forcing a call to the main method. This approach works fine because if there are other classes on the same project those classes will also call the dummy static method, but because static constructors are only called once per process then this will behave in the same way as it was with ActiveX Dlls. 

    NOTE: This is not the case for SingleUse classes inside ActiveX Exes because the main method is supposed to be called once per thread and .NET Assemblies by default only run in the same process. Please review the ActiveX EXE topic for more background and solutions.

    C# Target Code

    using System;

    namespace Project1
    {
      public class Class1
      {

        static Class1()
        {
         Module1.TriggerClassInitialization();
        }
       }
    }

    From that static constructor a dummy static method is called. That dummy method is only used to trigger the call of the migrated class static constructor to then generate a call to the Module main method, simulating the original behavior.

    C# Target Code

    using System;

    namespace Project1
    {
      public class Class1
      {

        static Class1()
        {
          Module1.TriggerClassInitialization();
        }
       }
    }


    Download VBUC Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration