您的应用程序中发生了未处理的异常...无法加载文件或程序集

时间:2018-03-24 19:56:10

标签: c# .net vb.net

当我的预开发应用程序在另一台计算机上打开时,我就面临着。显示此警告且应用程序未运行。

  

“您的应用程序中发生了未处理的异常。如果单击继续,应用程序将忽略此错误并尝试继续。如果单击退出,应用程序将立即关闭。”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.

1 个答案:

答案 0 :(得分:2)

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

  

System.TypeInitializationException:&#39; TopAuto.MAINMODULE&#39;的类型初始值设定项。抛出一个例外。 ---&GT; System.IO.FileNotFoundException:无法加载文件或程序集&#39; CrystalDecisions.Shared,Version = 10.5.3700.0,Culture = neutral,PublicKeyToken = 692fbea5521e1304&#39;或其中一个依赖项。系统找不到指定的文件。

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

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