【问题标题】:Unhandled exception has occurred in your application ... Could not load file or assembly您的应用程序中发生未处理的异常...无法加载文件或程序集
【发布时间】:2018-03-26 20:20:09
【问题描述】:

当我的预开发应用程序在另一台计算机上打开时,我遇到了这种情况。显示此警告且应用程序未运行。

“您的应用程序中发生了未处理的异常。如果您单击继续,应用程序将忽略此错误并尝试继续。如果您单击退出,应用程序将立即关闭。'TopAuto.MAINMODULE' 的类型初始化程序抛出一个例外。”

详情是:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.TypeInitializationException: The type initializer for 'TopAuto.MAINMODULE' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
File name: 'CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'
   at TopAuto.MAINMODULE..cctor()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

   --- End of inner exception stack trace ---
   at TopAuto.MAINMODULE.checkServer()
   at TopAuto.FrmLogin.btnLogIn_Click(Object sender, EventArgs e) in E:\A Sale Software Project\TopAuto\TopAuto\Form\FrmLogin.vb:line 292
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8762 (QFE.050727-8700)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
TopAuto
    Assembly Version: 22.0.7.14
    Win32 Version: 22.0.7.14
    CodeBase: file:///D:/newsoft/TopAuto.exe
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.7057 (QFE.050727-7000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8770 (QFE.050727-8700)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8653 (QFE.050727-8600)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8681 (QFE.050727-8600)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8771 (QFE.050727-8700)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
DevComponents.DotNetBar2
    Assembly Version: 7.0.0.4
    Win32 Version: 7.0.0.4
    CodeBase: file:///D:/newsoft/DevComponents.DotNetBar2.DLL
----------------------------------------
Accessibility
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7057 (QFE.050727-7000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8762 (QFE.050727-8700)
    CodeBase: file:///C:/Windows/assembly/GAC_64/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8773 (QFE.050727-8700)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.7057 (QFE.050727-7000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

【问题讨论】:

  • 它似乎缺少特定位置的文件。请附上相关代码和抛出异常的位置。
  • 阅读异常文本/消息告诉您的内容:“无法加载文件或程序集 'CrystalDecisions.Shared [...]' 或其依赖项之一。系统找不到文件指定。" 哪一部分你不明白?
  • 为什么这被标记为 VB6???

标签: c# .net vb.net


【解决方案1】:

第二段是对你问题的回答:

System.TypeInitializationException:“TopAuto.MAINMODULE”的类型初始化程序引发了异常。 ---> System.IO.FileNotFoundException: 无法加载文件或程序集 'CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' 或其依赖项之一。 系统找不到指定的文件。

虽然您已将应用程序编译为可执行文件,但它有一些依赖项:除了 .NET 库(如消息所述已成功加载)之外,它还需要一些名为 CrystalDecisions.Shared 的库以用于动态链接。

这个问题的解决方案几乎是困难的:您必须为应用程序提供所需的 dll,将其复制到可执行文件所在的同一目录(或文件夹结构中的相应相对路径),或者,更便携但更新更少的方式,重新编译应用程序并将其与库静态链接。这会将您的库包含到可执行文件本身中,从而生成一个 .exe 文件,该文件可以自行移动和复制。静态链接通常会带来更高的性能,因为您的程序可以简单地从一个地方跳转到另一个地方,而无需动态加载某些库,但这可能可以忽略不计并且与您的问题无关。

【讨论】:

    猜你喜欢
    • 2015-02-01
    • 2022-09-30
    • 2022-11-11
    • 1970-01-01
    • 2012-03-14
    • 2020-12-26
    • 1970-01-01
    • 2014-12-15
    相关资源
    最近更新 更多