Unity setting problem when defined in code

Posted by Xabatcha on Stack Overflow See other posts from Stack Overflow or by Xabatcha
Published on 2010-04-14T09:18:56Z Indexed on 2010/04/14 9:23 UTC
Read the original article Hit count: 218

Filed under:

I have problem when asking for default ILogger from Unity container. I have this setting defined in code (its VB.net)

Dim container As IUnityContainer
...
container.RegisterType(Of ILogger, NullLogger)()
container.RegisterType(Of ILogger, EntLibLogger)("EL")

When I am getting ILogger from container I may have different name, like:

 Ioc.Resolve(Of ILogger)("MyLogger")

However this raises error as the mapping is not set for 'MyLogger'. Can I force container to return type which was registered without name? Actually when I used setting from web.config it worked.

Any tips most welcome. Thanks. Cheers, X.

© Stack Overflow or respective owner

Related posts about unity