问题描述:
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)
基本代码: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
Courseware
程序集版本: 1.0.0.0
Win32 版本: 1.0.0.0
基本代码: file:///E:/系统网络版无OFFICE新版/Courseware.exe
System.Windows.Forms
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
System.Drawing
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
System
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
log4net
程序集版本: 1.2.11.0
Win32 版本: 1.2.11.0
基本代码: file:///E:/系统网络版无OFFICE新版/log4net.DLL
System.Core
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
System.Data.SQLite
程序集版本: 1.0.99.0
Win32 版本: 1.0.99.0
基本代码: file:///E:/系统网络版无OFFICE新版/System.Data.SQLite.DLL
System.Data
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
System.Xml
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
System.Transactions
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
DevComponents.DotNetBar2
程序集版本: 12.2.0.7
Win32 版本: 12.2.0.7
基本代码: file:///E:/系统网络版无OFFICE新版/DevComponents.DotNetBar2.DLL
System.Configuration
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
System.EnterpriseServices
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
System.Numerics
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
AxInterop.APlayer3Lib
程序集版本: 1.0.0.0
Win32 版本: 1.0.0.0
基本代码: file:///E:/系统网络版无OFFICE新版/AxInterop.APlayer3Lib.DLL
mscorlib.resources
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/mscorlib.resources.dll
System.Windows.Forms.resources
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/System.Windows.Forms.resources.dll
Accessibility
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
************** 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。