Reputation: 28558
I have a class:
public class Foo : IFoo
{
}
and two interfaces:
Public interface IFoo : IBar<SomeType>
{
}
public interface IBar<T>
{
DoSomething(T t);
}
We are using XML Config,the code configuration works fine, but the web.config doesn't.
The error is like:
Resolution of the dependency failed, type = "IFoo", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, IBar`1[SomeType], is an interface and cannot be constructed. Are you missing a type mapping?
mlns="http://schemas.microsoft.com/practices/2010/unity">
<alias alias="IFoo"
type="IFoo, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e4bf38905880b60b" />
<alias alias="Foo"
type="Foo, Something, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e4bf38905880b60b" />
<container name="SomeName">
<register type="IFoo" mapTo="Foo" />
</container>
</unity>
Upvotes: 1
Views: 505
Reputation: 1496
I believe you're probably using the default instance of the UnityContainer since you didn't mention anything about using a named instance of the container.
<container name="SomeName">
<register type="IFoo" mapTo="Foo" />
</container>
You're registering the mapping to "SomeName" instead of the default container.
Remove
name="SomeName"
Upvotes: 1