使用dll“AxInterop.Microsoft.Office.Interop.VisOcx.dll”(v4.0.30319)中的“AxDrawingControl”时出现“未注册类”异常

时间:2013-04-12 17:28:43

标签: visio

在我的应用程序中使用dll AxDrawingControl(v4.0.30319)中的AxInterop.Microsoft.Office.Interop.VisOcx.dll时,我收到以下异常:

System.Runtime.InteropServices.COMException occurred
HResult=-2147221164
Message=Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Source=System.Windows.Forms
ErrorCode=-2147221164

The 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:
  • 应用程序在Configuration Manager中配置为“Any CPU” - > “Active Solution Platform”
  • 当应用程序在Windows8 64位操作系统中作为64位应用程序执行时,该应用程序会抛出上述错误。
  • Visio安装是Professional 2010,x86版本。

    到目前为止,我的观察结果如下:

    1. 安装visio x64版本时,visio绘图控件加载正常。
    2. 如果将“Active Solution Platform”更改为x86版本,它也可以正常工作。

不幸的是,上述解决办法在我的情况下是不可能的,因为它是一次点击应用程序,并且客户端可以在安装了任何Visio版本的任何版本的Windows上运行。

问题:

  1. 应用程序可以配置为“任何CPU”并且仍支持visio 32和64位版本吗?
  2. 是否有任何替代方案/最佳做法来处理此类情况?

    • 例如:分别发布应用程序的32和64版本?
    • 或者是否可以随应用程序一起发送64位和32位版本的Visio dll,并在发生错误时在它们之间切换?
  3. 重建

    的步骤
    1. 在具有64位Windows操作系统的计算机上,在VS2010中创建一个新的Windows窗体项目。
    2. 在Configuration Manager中将项目配置为Any CPU - > Active Solution Platform
    3. 右键单击工具箱,然后点击Choose Items - >导航到COM Components标签 - >查看Microsoft Office Visio 14.0 Drawing Control
    4. Visio绘图控件现在将出现在工具箱中。
    5. Microsoft Office Visio 14.0 Drawing Control控件拖到表单中,然后按F5
    6. Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))错误会突然出现。
    7. 谢谢你, 问候, 普利文

0 个答案:

没有答案