Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3610164
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:43:05+00:00 2026-05-18T21:43:05+00:00

Oh! this is very strange issue. I’m going to register these two types, but

  • 0

Oh! this is very strange issue. I’m going to register these two types, but there is nothing to be work well.

<unity>
    <typeAliases>
        <typeAlias alias="IEqualityComparer`1"
                   type="System.Collections.Generic.IEqualityComparer`1, mscorlib" />
        <typeAlias alias="singleton"
                   type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity" />            
        <typeAlias alias="EqualityComparer`1"
                   type="System.Collections.Generic.EqualityComparer`1, mscorlib" />
    </typeAliases>
    <containers>
        <container>
            <types>
                <register type="IEqualityComparer`1"
                          mapTo="EqualityComparer`1">
                    <lifetime type="singleton" />
                </register>
            </types>
        </container>
    </containers>
</unity>

And this is my controller:

public class MyController : MyExtendedController {
    private readonly IEqualityComparer<int> _fakeComparer;

    public ResourcesController(IEqualityComparer<int> fakeComparer) {
        _fakeComparer = fakeComparer;
    }
}

And exception throws by Unity when resolving Controller:

Resolution of the dependency failed, type = "MyController", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type EqualityComparer`1 cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:
Resolving MyController,(none)
Resolving parameter "fakeComparer" of constructor   MyController(System.Collections.Generic.IEqualityComparer`1[[int, mscorelib]] fakeComparer)
Resolving System.Collections.Generic.EqualityComparer`1[int, mscorelib],(none) (mapped from System.Collections.Generic.IEqualityComparer`1[int, mscorelib], (none))

Any suggestions would be appreciated 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:43:05+00:00Added an answer on May 18, 2026 at 9:43 pm

    Updated answer

    The reason is that EqualityComparer<T> is an abstract class, as you can see on MSDN. Unity cannot instantiate abstract classes, you have to provide a concrete implementation.



    First answer

    Did you have configured your server:

    var container = new UnityContainer();
    var section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
    section.Containers.Default.Configure(container);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is very strange, but when I add the mysql_real_escape_string it doesn't load the
I have this very strange issue with my MVC 2 project. Often times, I'll
Very strange issue... I have something like this in my Controller: public ActionResult Initialize(IEnumerable<MyModel>
I've encountered a very strange issue using JMenuBar where navigating between two JMenus results
I have a very strange issue with PHP. I run this very simple code:
This is a very strange issue that is similar to a few other people
I spent few hours trying to resolve one very strange issue, but I really
This is a very strange issue. I'm trying to print a large text file,
We had a very strange issue on our servers this week, where a method
This is a very strange issue I am facing for a while now, when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.