Question

I have following class

namespace MyApplication.Services
{
    public class TagEqualityComparer : IEqualityComparer<Tag>{/*code goes here*/}
}

Now what I would like to register it in autofac using .config file based configuration:

<autofac>
    <components>
        <component type="MyApplication.Services.TagEqualityComparer, MyApplication.Services"
                   service="System.Collections.Generic.IEqualityComparer, mscorlib" />
    </components>
</autofac>

I have already spent whole sunday searching for solution I failed to find any. Other registrations, non templates, works perfectly but this one refuses. Any idea how to solve it?

Was it helpful?

Solution

You need to define the rest of the generic type to specify the parameter type. Something like this:

<component type="MyApplication.Services.TagEqualityComparer, MyApplication.Services"
               service="System.Collections.Generic.IEqualityComparer`1[[MyApplication.Services.Tag, MyApplication.Services]], mscorlib" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top