Problems moving VB.NET 2008 application source to new computer

rhawk
rhawk used Ask the Experts™
on
We had a consultant convert an old VB6 application to VB.NET 2008 last year. The machine the work was done on and that we compile on is getting long in the tooth and I have a new machine I am replacing it with. I have taken care to install XP SP3 on the new machine, which is what is on the old one. I then installed VS 2008 and put the source in the exact same location on the new machine (directory wise) as on the old one. When I first opened the solution on the new computer I saw that one reference had a yellow “!” warning. It was System.Web.Extensions. I corrected this by changing it’s setting from specific version =true to false, assuming the VS 2008 on the older machine was not at the latest update. Changing that setting removed the yellow “!” warning.
There is still at least one more problem. When compiling it fails with errors. The section of code that fails is:
#Region "Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        If m_vb6FormDefInstance Is Nothing Then
            m_vb6FormDefInstance = Me
        End If
        'This call is required by the Windows Form Designer.
        InitializeComponent()
        'Forms = New FormsCollection
        Forms.Add(Me)  'upgrade_maryz
    End Sub

And the offending line is the InitializeComponents().

The exception details are:
System.Runtime.InteropServices.COMException was unhandled
  ErrorCode=-2147221164
  Message="Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))"
  Source="System.Windows.Forms"
  StackTrace:
       at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
       at System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
       at System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
       at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
       at System.Windows.Forms.AxHost.CreateInstance()
       at System.Windows.Forms.AxHost.GetOcxCreate()
       at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
       at System.Windows.Forms.AxHost.CreateHandle()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.AxHost.EndInit()
       at dotNetUtility.frmMDIMain.InitializeComponent() in C:\Documents and Settings\cw7007\VBNET_Publish\dotNetUtility_Source\frmMain.vb:line 624
       at dotNetUtility.frmMDIMain..ctor() in C:\Documents and Settings\cw7007\VBNET_Publish\dotNetUtility_Source\frmMain.vb:line 19
       at dotNetUtility.ModuleMain.Main() in C:\Documents and Settings\cw7007\VBNET_Publish\dotNetUtility_Source\ModuleMain.vb:line 18
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:
Also when I try to do to the mainform design it shows me this:

                   To prevent possible data loss before loading the designer, the following errors must be resolved:       

                  
      
                   1 Error       
      
            Ignore and Continue       
                   Why am I seeing this page?       


      

      
             Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))              

      

             
Instances of this error (2)

1.             Hide Call Stack

at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
at System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
at System.Windows.Forms.AxHost.CreateInstance()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.set_Site(ISite value)
at System.ComponentModel.Container.Add(IComponent component, String name)
at System.ComponentModel.Design.DesignerHost.Add(IComponent component, String name)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType, String name)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object[] parameters, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.ComponentCodeDomSerializer.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object[] parameters, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(IDesignerSerializationManager manager, CodeStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager manager, String name, CodeStatementCollection statements)

2.             Hide Call Stack

at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
at System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
at System.Windows.Forms.AxHost.CreateInstance()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
at System.Windows.Forms.AxHost.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
at System.Windows.Forms.Form.ControlCollection.Add(Control value)
at System.Windows.Forms.Design.ControlDesigner.DesignerControlCollection.Add(Control c)


I really need to get this application to compile on this machine and I am not overly familiar with VS.NET.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:
Are you using Office Interop assemblies or any other COM components?
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
You are still using a non-.Net component (surely a COM component coming from VB6). You need to find it, register it properly and reference it.

If your application is not a web app, propably that System.Web.Extensions can be simply removed from the references.

Author

Commented:
CodeCruiser,
I do see Interop.Microsoft.Office.Core and Interop.Outlook. I also know they are needed as the application s communicates to Outlook and Word.

How do I know which references are com?

emoreau,
I am not sure if the app uses the web and I would rather play with removing references after it compiles again.

Both: In playing with this last week (as I said I am not a .net developer so take what I found with a grain of salt) it looked like interop.MSComDlg may have been on of the issues and the ComCntrls, but not sure.

Opening the project file in a text editor, here are the references it uses:
  <ItemGroup>
    <Reference Include="ADODB">
      <Name>adodb</Name>
      <HintPath>..\..\..\..\..\Program Files\Microsoft.NET\Primary Interop Assemblies\adodb.dll</HintPath>
      <AssemblyFolderKey>hklm\primary interop assemblies</AssemblyFolderKey>
    </Reference>
    <Reference Include="AxInterop.MSComctlLib">
      <Name>AxInterop.MSComctlLib</Name>
      <HintPath>bin\AxInterop.MSComctlLib.dll</HintPath>
    </Reference>
    <Reference Include="AxInterop.MSComDlg">
      <Name>AxInterop.MSComDlg</Name>
      <HintPath>bin\AxInterop.MSComDlg.dll</HintPath>
    </Reference>
    <Reference Include="CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL">
      <Private>False</Private>
    </Reference>
    <Reference Include="CrystalDecisions.Enterprise.Framework, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
    <Reference Include="CrystalDecisions.Enterprise.InfoStore, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
    <Reference Include="CrystalDecisions.ReportSource, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
    <Reference Include="CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
    <Reference Include="CrystalDecisions.Windows.Forms, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304">
      <Private>False</Private>
    </Reference>
    <Reference Include="DataGridViewColumns, Version=1.4.3.0, Culture=neutral, PublicKeyToken=26596b3a8d7c8940, processorArchitecture=MSIL" />
    <Reference Include="Interop.Excel">
      <Name>Interop.Excel</Name>
      <HintPath>..\UTILITY_upgrade20081002\bin\Interop.Excel.dll</HintPath>
    </Reference>
    <Reference Include="Interop.Microsoft.Office.Core">
      <Name>Interop.Microsoft.Office.Core</Name>
      <HintPath>..\Utility.NET\bin\Interop.Microsoft.Office.Core.dll</HintPath>
    </Reference>
    <Reference Include="Interop.MSAdodcLib">
      <Name>Interop.MSAdodcLib</Name>
      <HintPath>..\Utility.NET\bin\Interop.MSAdodcLib.dll</HintPath>
    </Reference>
    <Reference Include="Interop.MSComDlg">
      <Name>Interop.MSComDlg</Name>
      <HintPath>bin\Interop.MSComDlg.dll</HintPath>
    </Reference>
    <Reference Include="Interop.MSCommLib">
      <Name>Interop.MSCommLib</Name>
      <HintPath>..\Utility.NET\bin\Interop.MSCommLib.dll</HintPath>
    </Reference>
    <Reference Include="Interop.Outlook">
      <Name>Interop.Outlook</Name>
      <HintPath>bin\Interop.Outlook.dll</HintPath>
    </Reference>
    <Reference Include="Interop.Scripting">
      <Name>Interop.Scripting</Name>
      <HintPath>..\Utility.NET\bin\Interop.Scripting.dll</HintPath>
    </Reference>
    <Reference Include="Interop.VBRUN">
      <Name>Interop.VBRUN</Name>
      <HintPath>..\Utility.NET\bin\Interop.VBRUN.dll</HintPath>
    </Reference>
    <Reference Include="Interop.Word">
      <Name>Interop.Word</Name>
      <HintPath>..\UTILITY_upgrade20081002\bin\Interop.Word.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.VisualBasic">
      <Name>Microsoft.VisualBasic</Name>
    </Reference>
    <Reference Include="Microsoft.VisualBasic.Compatibility">
      <Name>Microsoft.VisualBasic.Compatibility</Name>
    </Reference>
    <Reference Include="Microsoft.VisualBasic.Compatibility.Data">
      <Name>Microsoft.VisualBasic.Compatibility.Data</Name>
    </Reference>
    <Reference Include="System">
      <Name>System</Name>
    </Reference>
    <Reference Include="System.Configuration" />
    <Reference Include="System.Data">
      <Name>System.Data</Name>
    </Reference>
    <Reference Include="System.Drawing">
      <Name>System.Drawing</Name>
    </Reference>
    <Reference Include="System.ServiceProcess" />
    <Reference Include="System.Web">
      <Name>System.Web</Name>
    </Reference>
    <Reference Include="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
    </Reference>
    <Reference Include="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll</HintPath>
    </Reference>
    <Reference Include="System.Windows.Forms">
      <Name>System.Windows.Forms</Name>
    </Reference>
    <Reference Include="System.Xml">
      <Name>System.XML</Name>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Import Include="Axmscomctl" />
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="System" />
    <Import Include="System.Collections" />
    <Import Include="System.Data" />
    <Import Include="System.Diagnostics" />
    <Import Include="System.Drawing" />
    <Import Include="System.Windows.Forms" />
  </ItemGroup>
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

Most Valuable Expert 2012
Top Expert 2014

Commented:

Author

Commented:
The main form does have this error description:

Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))      C:\Documents and Settings\cw7007\VBNET_Publish\dotNetUtility_Source\frmMain.vb      614      0      


Which is not overly helpful to me if it does not tell me what class is not registered. :(
Most Valuable Expert 2012
Top Expert 2014

Commented:
What is the frmMain line 614?

Author

Commented:
CodeCruiser: But the office interops are not causing any problems and I can open the forms that use them. They are not referenced or used on the main form. I would rather get the code to a state that is equal to the original machine so it compiles and runs, then worry about cleaning it up. I know it is not very clean and the original consultant did not seem like they relaly knew what they were doing, and I plan to learn this enough to clean it up. At least I can already modify code and recompile on the old machine, so I am learning. ;)

Author

Commented:
CodeCruiser: Line 614 says:         Me.Cursor = System.Windows.Forms.Cursors.Default

Is there a way to just jump to a given line number? I had to turn on line numbers to find what line it was.
Most Valuable Expert 2012
Top Expert 2014

Commented:
In the VS, you can see the line and column numbers in the right hand side of the status bar. May be a line above or below this is the problem source. Are there any other COM components being used? Did you install in PIAs on the new machine?
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
>>Is there a way to just jump to a given line number?

press CTRL-G

Author

Commented:
CodeCruiser:
Lines 609 to 614:
        Me.Controls.Add(Me.ToolStrip1)
        Me.Controls.Add(Me.ssStatus)
        Me.Controls.Add(Me.picPrintScreen)
        Me.Controls.Add(Me.imlToolbarIcons)
        Me.Controls.Add(Me.dlgCommonDialog)
        Me.Cursor = System.Windows.Forms.Cursors.Default

How do I tell what com components are there? And what is a PIA?

Author

Commented:
emoreau: I did the cntrl-G (since it works in VB6 and other programs) but it just moves my focus from inside the form source code to the Immediate Window.
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
Your key assignement is not standard. Open the Edit menu and check the key assignment of the "Go To ..." item.

Author

Commented:
emoreau,
Thank you. It had no assignment and in tools the editor was set to VB6. I changed it to default and now the goto line is set to cntrl-g.
Most Valuable Expert 2012
Top Expert 2014

Commented:
PIA is Office Primary Interop Assemblies. I dont see any COM related stuff in the above lines of code.

Author

Commented:
I set the debugging to include the .net stuff and not "Just my Code" and here is what IO now know, have:

When I debug into the initializeComponente I can follow it to the offending area. This line:

Me.imlToolbarIcons = New Axmscomctl.AxImageList

Is causeing issues in the routines. It leads eventually to this code in AxHost.cs:

        private void CreateInstance() {
            Debug.Assert(instance == null, "instance must be null");
            //Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "before created "+Windows.GetCurrentThreadId());
            //Debug.WriteStackTraceIf("AxHTrace");
            //checkThreadingModel();
            try {
                instance = CreateInstanceCore(this.clsid);
                Debug.Assert(instance != null, "w/o an exception being thrown we must have an object...");
            }
            catch (ExternalException e) {
                if (e.ErrorCode == unchecked((int)0x80040112)) { // CLASS_E_NOTLICENSED
                    throw new LicenseException(GetType(), this, SR.GetString(SR.AXNoLicenseToUse));
                }
                throw;
            }
 
            Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "created");
            SetOcState(OC_LOADED);
        }

Where the exception happend on the line that says throw;
Commented:
AH-HA! A friend I called just recomended installing VB6 SP6 on the machine as well. He said it may have components that the conversion still uses that either differ from the normal XP OS ones are are in addition to. So I just did that and VOILA! I can open the form now and it actually compiles and runs just fine!

So for future people with something like this problem with VB6 upgraded programs to VS 2008, make sure you have VB6 SP6 installed too!
Thanks for your help all!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial