没有注册类别 (异常来自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG))

jiechuze 2010-06-07 03:07:57
异常如下所示,可能是某个COM组件未注册(B超),但是项目下的dll文件我都测试了,始终是抛出这个异常。
未处理 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()
在 WindFormsApplication.Frm_Person.InitializeComponent() 位置 E:\一体机\WindFormsApplication\WindFormsApplication\WindFormsApplication\Frm_Person.Designer.cs:行号 681
在 WindFormsApplication.Frm_Person..ctor() 位置 E:\一体机\WindFormsApplication\WindFormsApplication\WindFormsApplication\Frm_Person.cs:行号 154
在 WindFormsApplication.userLogin.button3_Click(Object sender, EventArgs e) 位置 E:\一体机\WindFormsApplication\WindFormsApplication\WindFormsApplication\userLogin.cs:行号 39
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 WindFormsApplication.Program.Main() 位置 E:\一体机\WindFormsApplication\WindFormsApplication\WindFormsApplication\Program.cs:行号 18
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
...全文
53703 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
q169749 2012-11-13
  • 打赏
  • 举报
回复
引用 5 楼 kim 的回复:
解决办法:在项目属性里设置“生成”=>“目标平台”为x86而不是默认的ANY CPU.
大哥。。。我是英文版的,不知道对应的是啥啊。能不能说一下啊
fuckyouone 2012-11-12
  • 打赏
  • 举报
回复
我的也不行,可能是com不一样,导致原因也不同吧
Ben_jli 2012-10-29
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]

解决办法:在项目属性里设置“生成”=>“目标平台”为x86而不是默认的ANY CPU.
[/Quote]

果然有牛人!!!
dedemiu520 2012-10-21
  • 打赏
  • 举报
回复
能否详细说明?
看见彩虹 2012-09-19
  • 打赏
  • 举报
回复
为啥我的不行
jasonhw 2012-09-10
  • 打赏
  • 举报
回复
确实是好办法
[Quote=引用 5 楼 的回复:]

解决办法:在项目属性里设置“生成”=>“目标平台”为x86而不是默认的ANY CPU.
[/Quote]
hebeibeijing1234 2012-08-31
  • 打赏
  • 举报
回复
楼上正解,大赞!!![Quote=引用 5 楼 的回复:]

解决办法:在项目属性里设置“生成”=>“目标平台”为x86而不是默认的ANY CPU.
[/Quote]
hebeibeijing1234 2012-08-31
  • 打赏
  • 举报
回复
楼上正解,大赞!!![Quote=引用 5 楼 的回复:]

解决办法:在项目属性里设置“生成”=>“目标平台”为x86而不是默认的ANY CPU.
[/Quote]
C4PO 2012-06-25
  • 打赏
  • 举报
回复
解决办法:在项目属性里设置“生成”=>“目标平台”为x86而不是默认的ANY CPU.
liyf155 2011-08-26
  • 打赏
  • 举报
回复
同问。
jjjin80108 2011-08-04
  • 打赏
  • 举报
回复
兄弟,你这个问题解决了没?我也遇到了
壮士 2010-09-19
  • 打赏
  • 举报
回复
在注册表里咋查找呀???
zhu_jiang 2010-06-07
  • 打赏
  • 举报
回复
的确是com主件未注册的问题, com组件并不需要出现在你的程序目录下,所以光查找这是没用的,
你需要找到
System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)中的clsid,找一个可以运行程序的机器,打开注册表查找此clsid,找到后可以发现是那个com/ole组件,并可以获得路径,拷贝到自己机器程序的目录注册一下就行了

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧