【问题标题】:WPF application crashed with XamlParseException and System.IO.FileNotFoundException?WPF 应用程序因 XamlParseException 和 System.IO.FileNotFoundException 而崩溃?
【发布时间】:2014-10-31 10:09:00
【问题描述】:

我部署了我的 WPF(Windows Presentation Foundation)应用程序,它使用 .Net Framework 4.5 构建为 32bit 应用程序。 我在客户端机器上运行应用程序 (Windows 7 64bit)。这台机器安装了.Net Framework 4.5Visual C++ Redistributable Packages for Visual Studio 2013。启动时崩溃了。

我正在使用 Dependency Walker 来分析它,下面是 DW 的日志。


Starting profile on 10/31/2014 at 4:58:32 PM

Operating System: Microsoft Windows NT/2000/XP/2003/Vista based Ultimate (64-bit), version 6.01.7601 Service Pack 1
Program Executable: \\tuyetam-pc\users\administrator\desktop\mystic server setup 20141025\mystic server v2.0 alpha (32bit)\MYSTICSERVER.EXE
Program Arguments: 
Starting Directory: \\TUYETAM-PC\Users\Administrator\Desktop\Mystic Server Setup 20141025\Mystic Server v2.0 Alpha (32bit)\
Search Path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\

Options Selected:
     Simulate ShellExecute by inserting any App Paths directories into the PATH environment variable.
     Log DllMain calls for process attach and process detach messages.
     Hook the process to gather more detailed dependency information.
     Log LoadLibrary function calls.
     Log GetProcAddress function calls.
     Log first chance exceptions.
     Log debug output messages.
     Use full paths when logging file names.
     Automatically open and profile child processes.
--------------------------------------------------------------------------------

Started "\\tuyetam-pc\users\administrator\desktop\mystic server setup 20141025\mystic server v2.0 alpha (32bit)\MYSTICSERVER.EXE" (process 0xB64) at address 0x000C0000.  Successfully hooked module.
Loaded "c:\windows\syswow64\NTDLL.DLL" at address 0x77E10000.  Successfully hooked module.
Loaded "c:\windows\syswow64\MSCOREE.DLL" at address 0x71E30000.  Successfully hooked module.
Loaded "c:\windows\syswow64\KERNEL32.DLL" at address 0x75800000.  Successfully hooked module.
Loaded "c:\windows\syswow64\KERNELBASE.DLL" at address 0x773A0000.  Successfully hooked module.
DllMain(0x773A0000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\syswow64\KERNELBASE.DLL" called.
DllMain(0x773A0000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\syswow64\KERNELBASE.DLL" returned 1 (0x1).
DllMain(0x75800000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\syswow64\KERNEL32.DLL" called.
DllMain(0x75800000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\syswow64\KERNEL32.DLL" returned 1 (0x1).
Injected "c:\users\administrator\desktop\depends22_x86\DEPENDS.DLL" at address 0x08370000.
DllMain(0x71E30000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\windows\syswow64\MSCOREE.DLL" called.
DllMain(0x08370000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\users\administrator\desktop\depends22_x86\DEPENDS.DLL" called.
DllMain(0x08370000, DLL_PROCESS_ATTACH, 0x00000000) in "c:\users\administrator\desktop\depends22_x86\DEPENDS.DLL" returned 1 (0x1).
GetProcAddress(0x75800000 [c:\windows\syswow64\KERNEL32.DLL], "FlsAlloc") called from "c:\windows\syswow64\MSCOREE.DLL" at address 0x71E36F3C and returned 0x75814EE3.

STATUS_STACK_BUFFER_OVERRUN encountered
Entrypoint reached. All implicit modules have been loaded.
Exited "\\tuyetam-pc\users\administrator\desktop\mystic server setup 20141025\mystic server v2.0 alpha (32bit)\MYSTICSERVER.EXE" (process 0xB64) with code -1073740791 (0xC0000409).

当我尝试捕获应用程序异常时,异常信息如下

The error time: 11/2/2014 10:10 PM
Exception: System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'DVRServerInterface.MainWindow' that matches the specified binding constraints threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'CPPWrapper.dll' or one of its dependencies. The specified module could not be found.
   at DVRServerInterface.MainWindow..ctor()
   --- End of inner exception stack trace ---
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
   at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
   at System.Windows.Application.DoStartup()
   at System.Windows.Application.<.ctor>b__1(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)___   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
   at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
   at System.Windows.Application.DoStartup()
   at System.Windows.Application.<.ctor>b__1(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
InnerException.Message:Could not load file or assembly 'CPPWrapper.dll' or one of its dependencies. The specified module could not be found.

不是当我尝试在客户端机器上安装 Visual Studio 2013 时,程序运行正常。

还有更多信息:这是我的应用程序的 1.1 版

  • 在之前的版本(1.0)中,我使用了VS 2012和.Net 4.0,并成功部署了1.0版本。

  • 在此版本 (1.1) 中:我将所有项目更新到 VS 2013 并使用 .Net 4.5。所以我不知道这些步骤是否导致了问题?我需要将 .Net 4.5 用于 asyn/await 方法。

谁能告诉我问题?

非常感谢!

【问题讨论】:

  • 您是否尝试过在应用程序中捕获未处理的异常?
  • 您确定主窗口的 xaml 文件正确吗?
  • 请看我上面的更新,谢谢!

标签: c# .net wpf


【解决方案1】:

错误信息:

无法加载文件或程序集“CPPWrapper.dll”或其依赖项之一。找不到指定的模块。

表示它无法加载引用的程序集“CPPWrapper.dll”。通常这意味着该文件与可执行文件或 GAC 不在同一目录中,或者预期版本和实际版本不同。如果缺少来自“CPPWrapper.dll”的依赖程序集,也会出现这种情况。

给出名称,该程序集很可能是 C++ 包装程序集。这意味着它可能依赖于安装的外部库或框架文件(甚至可能是不同的处理器架构)。

分析依赖相关问题的有用工具是Fusion Log Viewer

【讨论】:

  • 是的,我考虑过这些案例,但 DW 无法告诉我确切的问题。
  • 我尝试在客户端机器上安装 Visual Studio 2013,程序运行良好。所以我不能使用 Fusion Log Viewer 来检测问题。你对我有什么建议吗。谢谢!
  • 不行,说明是缺少VS的安装组件。也许是正确的 VC++ 运行时或类似的东西。
  • 这取决于版本、操作系统等。也许反射器可以用来确定依赖关系。我相信你可以下载试用版。
  • 确定没有引入另一个依赖项或另一个版本的依赖项?如果你比较当时和现在的 csproj 文件,它是否显示出依赖关系的差异?
【解决方案2】:

今天,我尝试安装更多的2个组件:

  1. 适用于 Visual Studio 2010 的 Visual C++ 可再发行包
  2. 适用于 Visual Studio 2012 的 Visual C++ 可再发行包

实际上,这个应用程序从 2010 年开始使用 VS 2010 开发。然后我将项目更新为使用 VS 2012,现在是 VS 2013。

当这种方式可以解决我的问题时,我很高兴,但是有人可以解释一下发生了什么吗?

【讨论】:

    猜你喜欢
    • 2023-03-14
    • 2019-12-26
    • 2012-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多