diff --git a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs index 0edfe07..983c0e6 100644 --- a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs +++ b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs @@ -4,7 +4,7 @@ namespace RhSolutions.AddIn; public sealed class RhSolutionsAddIn : IExcelAddIn { - public static readonly Application Excel = (Application)ExcelDnaUtil.Application; + public static Application Excel { get; private set; } public static ServiceProvider ServiceProvider { get; private set; } public static IAddInConfiguration Configuration { get; private set; } @@ -14,6 +14,7 @@ public sealed class RhSolutionsAddIn : IExcelAddIn Services.AddHttpClient() .AddMemoryCache() + .AddSingleton((Application)ExcelDnaUtil.Application) .AddSingleton() .AddSingleton() .AddSingleton() @@ -43,6 +44,7 @@ public sealed class RhSolutionsAddIn : IExcelAddIn ServiceProvider = Services.BuildServiceProvider(); Configuration = ServiceProvider.GetService(); + Excel = ServiceProvider.GetService(); EventsUtil.Initialize();