错误:类未注册 [英] Error: class not registered
问题描述
您好,
我正在尝试使用Visual Basic Windows窗体应用程序打开microsoft office 2013 Excel。当我的程序试图让Excel打开时,我收到以下错误。
mscorlib.dll中出现类型'System.Runtime.InteropServices.COMException'的例外但是未在用户代码中处理
附加信息:由于以下原因,检索CLSID为{00024500-0000-0000-C000-000000000046}的组件的COM类工厂失败错误:80040154未注册类(HRESULT异常:0x80040154(REGDB_E_CLASSNOTREG))。
当我尝试运行代码时,它停在,
Hello,
I'm trying to use a Visual Basic windows form app to open microsoft office 2013 Excel. When my program tries to get Excel to open I get the following error.
An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll but was not handled in user code
Additional information: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
When I try to run the code it stops at,
Dim xlApp As New Excel.Application
并出现上述错误声明。
我的代码的开头是:
and the above error statement appears.
The beginning of my code is:
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
'Objects defined
Dim xlApp As New Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
我尝试了什么:
我是VB的新手并且不擅长调试。
What I have tried:
I'm new to VB and am not good at debugging.
推荐答案
该错误意味着您编写此代码的Excel版本未安装在计算机上。
That error means that the version of Excel you wrote this code against is not installed on the machine.
谢谢Dave ---我查了一下并且确认,我已经从快捷方式发布了。这促使我对安装进行了修复,解决了这个问题。虽然我不确定究竟修复了什么。
感谢大家的回复!
Thanks Dave---I checked, and confirmed, that I have been launching from a shortcut. This prompted me to do a repair on the install which has solved the issue. Although I'm not sure what exactly was repaired.
Thanks for everyone's responses!
这篇关于错误:类未注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!