From 476eaba519f0ef1e90db724bd3093dd2d01c3a05 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Wed, 8 Nov 2023 16:15:27 -0500 Subject: [PATCH] fix: added method to resolve old plugin assesmbly names & get version info --- src/PepperDash.Essentials/ControlSystem.cs | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/PepperDash.Essentials/ControlSystem.cs b/src/PepperDash.Essentials/ControlSystem.cs index 812c15bb..a317b9fa 100644 --- a/src/PepperDash.Essentials/ControlSystem.cs +++ b/src/PepperDash.Essentials/ControlSystem.cs @@ -31,6 +31,29 @@ namespace PepperDash.Essentials DeviceManager.Initialize(this); SecretsManager.Initialize(); SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true; + + AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve; + } + + private System.Reflection.Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs args) + { + var assemblyName = new System.Reflection.AssemblyName(args.Name).Name; + if (assemblyName == "PepperDash_Core") + { + return System.Reflection.Assembly.LoadFrom("PepperDashCore.dll"); + } + + if (assemblyName == "PepperDash_Essentials_Core") + { + return System.Reflection.Assembly.LoadFrom("PepperDash.Essentials.Core.dll"); + } + + if (assemblyName == "Essentials Devices Common") + { + return System.Reflection.Assembly.LoadFrom("PepperDash.Essentials.Devices.Common.dll"); + } + + return null; } /// @@ -141,13 +164,11 @@ namespace PepperDash.Essentials string directoryPrefix; - directoryPrefix = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationRootDirectory(); + directoryPrefix = Directory.GetApplicationRootDirectory(); - var fullVersion = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); + var fullVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); - AssemblyInformationalVersionAttribute fullVersionAtt = fullVersion[0] as AssemblyInformationalVersionAttribute; - - Global.SetAssemblyVersion(fullVersionAtt.InformationalVersion); + Global.SetAssemblyVersion(fullVersion); if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS {