Kentico / ADImport

Kentico Xperience Active Directory Import Utility is an application which allows importing of users and groups (roles) from Active Directory into Kentico Xperience.
https://www.xperience.io
MIT License
3 stars 2 forks source link

Experiencing IOC initialization error for command line on Kentico 13 #25

Open adamjudd79 opened 1 year ago

adamjudd79 commented 1 year ago

Brief bug description

What went wrong? An IOC initialization error occurs on the Command Line branch, under some circumstances:

CMS.Core.ServiceResolutionException HResult=0x80131500 Message=Resolution of 'CMS.Core.IAppSettingsService' failed with the following error: IoC container cannot be used for service resolution because it was not initialized yet. This means that the application was not properly pre-initialized or yet initialized. Use 'CMS.Core.Service.InitializeContainer' to perform container initialization. Source=CMS.Core StackTrace: at CMS.Core.IoCContainer.Resolve[TService]() at CMS.Core.Service.Resolve[TService]() at CMS.IO.AbstractStorageProvider.CreateDefaultProvider() at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Func`1 valueFactory) at CMS.IO.AbstractStorageProvider.get_DefaultProvider() at CMS.IO.File.OpenRead(String path) at ADImport.Program.Main(String[] args) in C:\Users\adam.judd\Downloads\ADImport-master\ADImport-master\ADImport\Program.cs:line 115

This exception was originally thrown at this call stack: CMS.Core.IoCContainer.ServiceProvider.get() CMS.Core.IoCContainer.Resolve()

Inner Exception 1: InvalidOperationException: IoC container cannot be used for service resolution because it was not initialized yet. This means that the application was not properly pre-initialized or yet initialized. Use 'CMS.Core.Service.InitializeContainer' to perform container initialization.

Additional context

Our resolution was to move the line (in Program.cs) that initializes the IOC for the Windows Forms to both branches:

CMSApplication.PreInit();