From 68512dba2bb077cbff9d3f2156308fccae684917 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Tue, 28 Mar 2023 07:33:13 +0300 Subject: [PATCH] Add Application Singleton --- RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs index 19ae437..58002ee 100644 --- a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs +++ b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs @@ -8,7 +8,7 @@ using System.Net; namespace RhSolutions.AddIn { - public class RhSolutionsAddIn : IExcelAddIn + public sealed class RhSolutionsAddIn : IExcelAddIn { public static Application Excel { get; private set; } public static ServiceProvider ServiceProvider { get; set; } @@ -17,15 +17,16 @@ namespace RhSolutions.AddIn public void AutoOpen() { IServiceCollection Services = new ServiceCollection(); - Excel = (Application)ExcelDnaUtil.Application; Services.AddHttpClient() .AddSingleton() - .AddSingleton(); + .AddSingleton() + .AddSingleton(ExcelDnaUtil.Application); ServiceProvider = Services.BuildServiceProvider(); Configuration = ServiceProvider.GetService(); - + Excel = ServiceProvider.GetService(); + IntelliSenseServer.Install(); EventsUtil.Initialize();