【问题标题】:.NET WPF runtime error after installing with Visual Studio Installer使用 Visual Studio 安装程序安装后的 .NET WPF 运行时错误
【发布时间】:2020-05-01 12:05:55
【问题描述】:

我正在使用 this 方法在我的 WPF 应用程序中注册一个全局热键。从 Visual Studio 调试或运行时它工作正常,但在使用 Visual Studio 安装程序项目发布应用程序并将其安装到我的 PC 后,应用程序会引发以下错误(来自事件查看器)。

我尝试过的事情:

  • 以管理员身份运行,
  • 禁用 Windows Defender,
  • 在另一台没有防病毒软件的 Windows 10 电脑上运行
  • 在 x86 配置中构建

错误信息:

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.IOException
   at MS.Internal.AppModel.ResourcePart.GetStreamCore(System.IO.FileMode, System.IO.FileAccess)
   at System.IO.Packaging.PackagePart.GetStream(System.IO.FileMode, System.IO.FileAccess)
   at System.IO.Packaging.PackagePart.GetStream()
   at System.Windows.Application.LoadComponent(System.Uri, Boolean)
   at System.Windows.Application.DoStartup()
   at System.Windows.Application.<.ctor>b__1_0(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Application.RunDispatcher(System.Object)
   at System.Windows.Application.RunInternal(System.Windows.Window)
   at System.Windows.Application.Run(System.Windows.Window)
   at MyAppName.App.Main()

接着是:

Faulting module name: KERNELBASE.dll, version: 10.0.18362.778, time stamp: 0x692cf0ab
Exception code: 0xe0434352
Fault offset: 0x00114192
Faulting process id: 0x274
Faulting application start time: 0x01d61fae9d4b314d
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: d5ca4cee-54ea-4f22-a2e5-86674c74d942
Faulting package full name: 
Faulting package-relative application ID:

【问题讨论】:

  • 看起来缺少运行时或您未包含的某些文件。我会先尝试]Assembly Binding Log Viewer](docs.microsoft.com/en-us/dotnet/framework/tools/…)。从开发人员命令提示符启动(在开始菜单上搜索)。这是more on dependency scanning。也许check this comment and its links.
  • @SteinÅsmul fuslogvw 没有显示任何内容。我使用 ClickOnce 向导发布应用程序并得到相同的结果 - ClickOnce 不应该包含所有必需的依赖项吗?
  • 确保将 fislogvw 设置为“记录所有绑定到磁盘”或类似内容。那里应该有东西。除此之外,here are some debugging ideas.
  • 确实是缺少运行时,但不是我预期的 :)
  • 去过那里,这是肯定的。我们能问一下它是什么吗?可能与发现此内容的人有关。

标签: c# .net dll windows-installer global-hotkey


【解决方案1】:

问题确实是缺少 dll - app resources.dll。显然 WPF 应用程序总是附带文化文件夹(默认为 en-US)。它被复制到构建时的输出目录(.\bin\Debug\en-US),但 Visual Studio 安装程序不会选择它,必须手动添加。

在 VS Installer 项目的文件系统中完成 -> 新建项目输出...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-08
    • 1970-01-01
    • 2022-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多