Win8 x64環境下VS2010 C#工程運行報錯:沒有注冊類 (異常來自 HRESULT:0x80040154


來源:http://blog.sina.com.cn/s/blog_7095482001019c2v.html

問題描述:

在Win8 x64環境下,VS2010的C#工程中引用了COM組件(Active X控件,且已正確注冊),可是一運行工程就會報如下異常錯誤:

未處理 System.Runtime.InteropServices.COMException
  Message=沒有注冊類 (異常來自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG))
  Source=System.Windows.Forms
  ErrorCode=-2147221164
  StackTrace:
       在 System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
       在 System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
       在 System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
       在 System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
       在 System.Windows.Forms.AxHost.CreateInstance()
       在 System.Windows.Forms.AxHost.GetOcxCreate()
       在 System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
       在 System.Windows.Forms.AxHost.CreateHandle()
       在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       在 System.Windows.Forms.AxHost.EndInit()
       在 ORI.GTJDA.ImageProcessingControl.ImageViewControl.InitializeComponent()

解決辦法:

造成上述錯誤的罪魁禍首就是工程文件“屬性--生成”中的目標平台造成的,如下圖,如果選擇Any CPU或者x64就會出現上述問題,將它設置為x86,問題得以解決。

image


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM