HASS.Agent: Bug: HASS.Agent crashes under Server 2016

Updated to 2022.12, and whenever I start up HASS.Agent I get a message saying it has stopped working and crashes.

Application: HASS.Agent.exe
CoreCLR Version: 6.0.322.12309
.NET Version: 6.0.3
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException: The type initializer for 'WinRT.ActivationFactory`1' threw an exception.
 ---> System.Runtime.InteropServices.COMException (0x80040154): ClassFactory cannot supply requested class

   at WinRT.BaseActivationFactory..ctor(String typeNamespace, String typeFullName)
   at WinRT.ActivationFactory`1..ctor()
   at WinRT.ActivationFactory`1..cctor()
   --- End of inner exception stack trace ---
   at WinRT.ActivationFactory`1.As(Guid iid)
   at Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager.Make___objRef_global__Windows_Media_Control_IGlobalSystemMediaTransportControlsSessionManagerStatics()
   at Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager.get__objRef_global__Windows_Media_Control_IGlobalSystemMediaTransportControlsSessionManagerStatics()
   at HASS.Agent.Media.MediaManager.MediaMonitor()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
   at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()
Faulting application name: HASS.Agent.exe, version: 2022.12.0.0, time stamp: 0x6283e0e1
Faulting module name: KERNELBASE.dll, version: 10.0.14393.5125, time stamp: 0x626ca997
Exception code: 0xe0434352
Fault offset: 0x0000000000034f08
Faulting process id: 0x1aa4
Faulting application start time: 0x01d8922a71a79c06
Faulting application path: C:\Users\Stuke00\AppData\Roaming\LAB02 Research\HASS.Agent\HASS.Agent.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report Id: 5f2eb168-9d03-49de-b7ad-eee06894c52a
Faulting package full name: 
Faulting package-relative application ID: 

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

MediaManager is a new adition (seems to be added with commit b348431 in this release

As MediaMonitor() is started as a “free” Task, any exceptions crash the entire application https://github.com/LAB02-Research/HASS.Agent/blob/fd496dd0643fcec0b23fd1ed23a85d45b29699eb/src/HASS.Agent/Media/MediaManager.cs#L40

Two optons are

  • Add a try to line 48
  • Move sessionManager request to outside of the task, so the exception will be catch by the media initialization

@RafaelEstevamReis suggested workaround is effective, just tested on a W7 environment. Will be rolling out in the next beta.

Thanks!