Share via

Trying to figure out why ocx file wont load form.

Zach M 20 Reputation points
2024-04-15T19:15:47.7333333+00:00

Program is able to run perfectly fine, but when trying to edit the form you get:

Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))Now the RBarcodex.ocx in question is registered to the system since the program is able to run in "run time" and run once is compiled.

User's image

Developer technologies | Windows Forms
{count} votes

Answer accepted by question author
  1. RLWA32 52,256 Reputation points
    2024-04-15T19:24:11.7966667+00:00

    The bitness of an .ocx control must match the bitness of the process into which it is being loaded. Since VS2022 is now a 64-bit process a 32-bit .ocx will not be loaded by the designer. Similarly, previous versions of VS were 32-bit processes and were incapable of loading a 64-bit COM component in their designers.


1 additional answer

Sort by: Most helpful
  1. RLWA32 52,256 Reputation points
    2024-04-17T00:41:04.96+00:00

    I used VS2019 to create a 32-bit .ocx control (MFCActiveX). I added the control to a .Net Framework Winforms project using VS2019. The I copied the Winforms project and the 32-bit .ocx control to a different VM that has VS2022 17.9 installed.

    I registered the 32-bit .ocx control with regsvr32.exe and using notepad added the following line to the Winforms project properties.

    <UseWinFormsOutOfProcDesigner>True</UseWinFormsOutOfProcDesigner>
    

    This project property was discussed in the .Net blog article WinForms Designer Selection for 32-bit .NET Framework Projects. I added this to the .csproj for the Winforms project BEFORE I opened it in VS2022.

    The project opened and the out-of-process designer loaded my test form with the 32-bit .ocx on it.

    MFCActiveXDesigner

    And the same solution works just as well in a VB .Net Framework Winforms project --

    MFCVBActiveXDesigner


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.