Klaus Nji
Klaus Nji

Reputation: 18857

Unity ignoring type mapping in app.config

I have the following settings in the appropriate sections of my app.config:

<alias alias="resourceManager" 
       type="Infrastructure.Dictionary.Localization.IResourceManager, Infrastructure.Dictionary" />

<register type="resourceManager"
          mapTo="Infrastructure.Dictionary.Localization.LocalizeDictionaryWrapper, Infrastructure.Dictionary" 
          name="Default">
    <lifetime type="singleton" />        
</register> 

When I call container.Resolve(NonLocalizedStrings.Default);

I get the following exception:

"Resolution of the dependency failed, type = "Infrastructure.Dictionary.Localization.IResourceManager", name = "Default".Exception occurred while: while resolving. Exception is: InvalidOperationException - The current type, Infrastructure.Dictionary.Localization.IResourceManager, is an interface and cannot be constructed. Are you missing a type mapping? At the time of the exception, the container was: Resolving Infrastructure.Dictionary.Localization.IResourceManager,Default"

Why is Unity ignoring my mapping?

Upvotes: 0

Views: 497

Answers (1)

Klaus Nji
Klaus Nji

Reputation: 18857

My bad. I am attempting to resolve a type before Unity has had the chance to configure its container.

Upvotes: 1

Related Questions