HASS.Agent icon indicating copy to clipboard operation
HASS.Agent copied to clipboard

Bug: HASS.Agent crashes under Server 2016

Open Stuke00 opened this issue 3 years ago • 9 comments

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: 

Stuke00 avatar Jul 07 '22 17:07 Stuke00

Can you run winver.exe and post a screenshot of its info

LAB02-Admin avatar Jul 07 '22 20:07 LAB02-Admin

Capture

I've been using this for several months but after I updated, it stopped.

Stuke00 avatar Jul 07 '22 23:07 Stuke00

Hm, looks like it's fully up-to-date, so it should work since Server 2016 uses the same code base as Windows 10. Give me some time to setup a Server 2016 environment to test and see if I can get it working. In the meantime, you can uninstall the current version (no settings will get lost) and temporarily install the previous version.

LAB02-Admin avatar Jul 08 '22 06:07 LAB02-Admin

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 avatar Jul 08 '22 23:07 RafaelEstevamReis

I have the same Problem with Windows Server 2012R2 (Version 6.3, Build 9600, NET Framework 4.8) I can install HASS.agent, but can't call the program window to configure it. Greetings, Eckart

Eckart0 avatar Jul 17 '22 17:07 Eckart0

I'm currently on vacation, when I get back (end of the week) I'll work on it

LAB02-Admin avatar Jul 18 '22 13:07 LAB02-Admin

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

Thanks!

LAB02-Admin avatar Aug 03 '22 12:08 LAB02-Admin

Implemented in the latest beta, let me know how it goes: https://github.com/LAB02-Research/HASS.Agent/releases/tag/2022.13.0-beta2

LAB02-Admin avatar Aug 12 '22 15:08 LAB02-Admin

Sorry for the delay, I finally got around to installing the new beta2 and it no longer crashes. However, it no longer reports storage capacity. storage sensor1 Screenshot 2022-08-28 073745 It only now shows the storage label and the number of disks.

Stuke00 avatar Aug 28 '22 12:08 Stuke00

Most multivalue sensors now use attributes:

image

LAB02-Admin avatar Sep 22 '22 08:09 LAB02-Admin

Yeah I don’t like that since I use sensors to easily track state changes. Sent from my iPhoneOn Sep 22, 2022, at 03:45, LAB02 Research | Sam @.***> wrote: Most multivalue sensors now use attributes:

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

Stuke00 avatar Sep 22 '22 12:09 Stuke00

You can use template sensors to convert any of them into regular ones.

LAB02-Admin avatar Sep 22 '22 14:09 LAB02-Admin

Ok I see. I may have to look into how to do that. Thanks!  Sent from my iPhoneOn Sep 22, 2022, at 09:04, LAB02 Research | Sam @.***> wrote: You can use template sensors to convert any of them into regular ones.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

Stuke00 avatar Sep 22 '22 14:09 Stuke00

I took the liberty of writing an example for you:

template:
  sensor:
  - storage_capacity_c:
      friendly_name: "Storage Capacity Drive C"
      unit_of_measurement: "MB"
      value_template: "{{ state_attr('sensor.hass_agent_storage_c', 'AvailableSpaceMB') | float(0) }}"

Make sure to change sensor.hass_agent_storage_c to the drive's sensor, and AvailableSpaceMB to the attribute you want to use. The | float(0) part converts it to a number-based value, you can drop that if you want text.

Reboot HA, and it'll show up as sensor.storage_capacity_c.

LAB02-Admin avatar Sep 22 '22 14:09 LAB02-Admin

Awesome thanks!  I’ll have to give this a try sometime this week. Sent from my iPhoneOn Sep 22, 2022, at 09:50, LAB02 Research | Sam @.***> wrote: I took the liberty of writing an example for you: template: sensor:

  • storage_capacity_c: friendly_name: "Storage Capacity Drive C" unit_of_measurement: "MB" value_template: "{{ state_attr('sensor.hass_agent_storage_c', 'AvailableSpaceMB') | float(0) }}"

Make sure to change sensor.hass_agent_storage_c to the drive's sensor, and AvailableSpaceMB to the attribute you want to use. The | float(0) part converts it to a number-based value, you can drop that if you want text.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

Stuke00 avatar Sep 25 '22 14:09 Stuke00