Skip to content

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

@adamjudd79

Description

@adamjudd79

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.ResolveTService
at CMS.Core.Service.ResolveTService
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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions