none
"Class not registered" exception when using the “AxDrawingControl” from the dll “AxInterop.Microsoft.Office.Interop.VisOcx.dll” (v4.0.30319) RRS feed

  • Question

  • Hi,

     I am getting the below exception when using the “AxDrawingControl” from the dll “AxInterop.Microsoft.Office.Interop.VisOcx.dll” (v4.0.30319) in my application

    System.Runtime.InteropServices.COMException occurred

      HResult=-2147221164

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

      Source=System.Windows.Forms

      ErrorCode=-2147221164

      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 TestVisOcxAxDrawing.VisioTestForm.InitializeComponent() in C:\ TestVisio\TestVisOcxAxDrawing\VisioTestForm.Designer.cs:line 55

      InnerException:

    • 1.       The application is configured as “Any CPU” in the Configuration Manager -> “Active Solution Platform”
    • 2.       The app is throwing the above error when it is executed as a 64bit application in Windows8 64bit OS.
    • 3.       Visio installation is Professional 2010, x86 version.

     Here are my observations so far:

    • 1.       The visio drawing control loads fine when visio x64 version is installed.
    • 2.       It also works fine if the “Active Solution Platform” is changed to x86 version.

    Unfortunately both the above work-arounds are not possible in my case as it is a click once application and the clients could be running on any version of windows with any Visio version installed.

    Questions:

    1. Can the application be configured as "Any CPU" and still support both visio 32 and 64 bit versions.
    2. Are there any alteranatives/best practices to handle such scenarios?
    •    eg:-, releasing 32 and 64 versions of the app separately or
    •    Is it possible to ship both 64 and 32 bit versions of the Visio dlls along with the app and switch between them when an error happens? 

    Steps to recreate

    1.        Create a new Windows form project in VS2010 on a machine with 64 bit Windows OS.
    2.        Configure the project as “Any CPU” in the Configuration Manager -> “Active Solution Platform”.
    3.        Right click on the toolbox and click “Choose Items” -> navigate to “COM Components” tab -> Check “Microsoft Office Visio 14.0 Drawing Control”.
    4.        The Visio drawing control will appear on the toolbox now.
    5.        Drag the “Microsoft Office Visio 14.0 Drawing Control” control into a form and press F5.
    6.        The “Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))” error will throw up.

    Thank you,

    Regards,

    Praveen


    Friday, April 12, 2013 5:10 PM

Answers

  • It's not the environment that the x32/x64 refers to, it is the version of Visio that is installed on the system that is being checked. The correct activex control comes with the installation of the full Visio product on the system (as well as the necessary dll's to support it). At a minimum if you are going to attempt to write a single app for both platforms you will have to check the installed visio before calling any form that has the control embedded to ensure that the correct platform is being used. Since you can't develop both scenarios on the same system (the requirement that x32/x64 cannot install together) you're going to have to merge the two versions after your build as part of compiling the installation package.

    There were some discussions over on Chris Roth's site (www.visguy.com) about these challanges.

    al


    If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Al Edlund Visio MVP

    Saturday, April 13, 2013 8:56 PM

All replies

  • "Can the application be configured as "Any CPU" and still support both visio 32 and 64 bit versions."

    The activex control used is based upon the version of Visio that is installed on the client system (since it relies upon the installed libraries). Thus you have to specify the client install, not the OS install, when developing the App. Since you cannot install both an x86 and an x64 version of Visio on the same system, this drives you to the requirement of having two systems (I have a real and a virtual) for when you want to play with both versions.

    al


    If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Al Edlund Visio MVP

    Friday, April 12, 2013 9:29 PM
  • Thank you Edlund for the quick reply.

     I was hoping to register/GAC the 64 bit visio dlls and run the app by referencing these dlls from GAC (on a 64 bit environment). This doesn't seems to be working; will you be able to throw some light into any such possibility.

    Saturday, April 13, 2013 10:17 AM
  • It's not the environment that the x32/x64 refers to, it is the version of Visio that is installed on the system that is being checked. The correct activex control comes with the installation of the full Visio product on the system (as well as the necessary dll's to support it). At a minimum if you are going to attempt to write a single app for both platforms you will have to check the installed visio before calling any form that has the control embedded to ensure that the correct platform is being used. Since you can't develop both scenarios on the same system (the requirement that x32/x64 cannot install together) you're going to have to merge the two versions after your build as part of compiling the installation package.

    There were some discussions over on Chris Roth's site (www.visguy.com) about these challanges.

    al


    If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Al Edlund Visio MVP

    Saturday, April 13, 2013 8:56 PM