问题描述:
C# WinForm程序用了第三方的控件DevComponents.DotNetBar2.dll,所用的DotNetBar2是破解的安装版。应用程序是Visual studio 2010上开发的,开发时本机能正常使用,
但是编译完成后,发到其他电脑上运行报错,错误截图如下:
点开【详细信息】如下:
有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。
************** 异常文本 **************
System.Runtime.InteropServices.COMException (0x80040154): 没有注册类 (异常来自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG))
在 System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
在 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.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
在 System.Windows.Forms.ScrollableControl.OnVisibleChanged(EventArgs e)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 DevComponents.DotNetBar.Metro.MetroTabPanel.set_Visible(Boolean value)
在 DevComponents.DotNetBar.Metro.MetroTabItem.?()
在 DevComponents.DotNetBar.Metro.MetroTabItem.set_Panel(MetroTabPanel value)
在 Courseware.MainForm.InitializeComponent() 位置 D:\workspace_vs2010\CoursewareNetImage\Courseware\MainForm.designer.cs:行号 391
在 Courseware.MainForm..ctor(LoginForm loginForm) 位置 D:\workspace_vs2010\CoursewareNetImage\Courseware\MainForm.cs:行号 35
在 Courseware.LoginForm.button1_Click(Object sender, EventArgs e) 位置 D:\workspace_vs2010\CoursewareNetImage\Courseware\LoginForm.cs:行号 513
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************
mscorlib
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
Courseware
程序集版本: 1.0.0.0
Win32 版本: 1.0.0.0
System.Windows.Forms
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
System.Drawing
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
System
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
log4net
程序集版本: 1.2.11.0
Win32 版本: 1.2.11.0
System.Core
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
System.Data.SQLite
程序集版本: 1.0.99.0
Win32 版本: 1.0.99.0
System.Data
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
System.Xml
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
System.Transactions
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
DevComponents.DotNetBar2
程序集版本: 12.2.0.7
Win32 版本: 12.2.0.7
System.Configuration
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
System.EnterpriseServices
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
System.Numerics
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
AxInterop.APlayer3Lib
程序集版本: 1.0.0.0
Win32 版本: 1.0.0.0
mscorlib.resources
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
System.Windows.Forms.resources
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
Accessibility
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
************** JIT 调试 **************
要启用实时(JIT)调试,
该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
jitDebugging 值。
编译应用程序时还必须启用
调试。
例如:
启用 JIT 调试后,任何未经处理的异常
都将被发送到在此计算机上注册的 JIT 调试器,
而不是由此对话框处理。
我经过分析,发现DevComponents.DotNetBar2.dll在开发电脑上已经写入了注册表,应该是注册到了全局程序集GAC,如下图:
通过查找应用程序中代码{DevComponents.DotNetBar.Metro.MetroShell metroShell1;}的类的定义,也应验了实际上我的程序里使用的DevComponents.DotNetBar的类都是来自于GAC,如下图所示:
我现在的疑问是:C#项目根目录下已经存放了一个DevComponents.DotNetBar2.dll文件,并且已添加了此dll文件的引用(见下图),为什么程序最终使用的DevComponents.DotNetBar2.dll却是来自GAC而不是项目引入的dll,如何在C#项目中改变dll的程序集指向,不要用GAC的程序集?(因为使用这个应用程序的电脑不可能安装GAC全局程序集)
P.S. 网上查了各种资料,有的说是使用.net framework 4.0及项目的setup属性改成x86,这些设置我都已查验过,开发电脑上设置都是对的,非开发用的电脑上也确认安装的是.net framework 4.0。
你先应该把你开发电脑中的程序生成的debug放进非开发的电脑上,看看能不能运行使用,不行的话那就是dll引用问题了。
还有可以将程序打包成安装程序,在非开发电脑上安装运行
感觉你这个和.net framework 4.0 版本有关,看你的好多dll都不能用。