0

I'm registering a global hotkey in my WPF application using exactly this approach. It works fine when debugging or running from Visual Studio, but after publishing app with Visual Studio Installer project and installing it on my PC, app throws following errors (from Event Viewer).

Things I've tried:

  • running as administrator,
  • disabling Windows Defender,
  • running on another Windows 10 PC with no antivirus
  • building in x86 configuration

Error message:

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()

Followed by:

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:
Jarek Danielak
  • 394
  • 4
  • 18
  • Looks like a missing runtime or some file you are not including. I would try the ]Assembly Binding Log Viewer](https://learn.microsoft.com/en-us/dotnet/framework/tools/fuslogvw-exe-assembly-binding-log-viewer) first. Launch from Developer command prompt (search for it on start menu). Here is [more on dependency scanning](https://stackoverflow.com/a/51940598/129130). And maybe [check this comment and its links](https://stackoverflow.com/questions/57359823/how-to-get-oracle-managedaccess-driver-to-work-with-installed-vb-net-applicati#comment101208468_57359823). – Stein Åsmul May 01 '20 at 15:37
  • @SteinÅsmul fuslogvw didn't show anything. I publish the app with ClickOnce wizard and got the same result - isn't ClickOnce supposed to include all required dependencies? – Jarek Danielak May 01 '20 at 16:01
  • Make sure to set the fislogvw to "log all binds to disk" or similar. Should be something there. Apart from that, [here are some debugging ideas](https://stackoverflow.com/questions/53512998/desktop-applicaton-not-opening-after-installation-in-client-system/53530377#53530377). – Stein Åsmul May 01 '20 at 16:12
  • It was indeed a missing runtime but not what I expected :) – Jarek Danielak May 08 '20 at 14:37
  • Been there, that's for sure. Can we ask what it was? Might be relevant for whoever finds this. – Stein Åsmul May 08 '20 at 14:44
  • I've posted my answer – Jarek Danielak May 08 '20 at 14:44

1 Answers1

0

The problem was indeed a missing dll - app resources.dll. Apparently WPF app is always shipped with culture folder (en-US by default). It's copied to output directory on build (.\bin\Debug\en-US) but Visual Studio Installer doesn't pick it up and it has to be added manually.

It's done in VS Installer project's File System -> new Project Output...

enter image description here

Jarek Danielak
  • 394
  • 4
  • 18