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 8189275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:13:27+00:00 2026-06-07T03:13:27+00:00

I have inherited a code base that makes use of the Castle Windsor IoC

  • 0

I have inherited a code base that makes use of the Castle Windsor IoC container, we have recently been forced to upgrade version v2.5.2 from 3.0.0 from due to another compatibility issue.

Following the upgrade to v3.0.0, the following extension method in one of our test classes fails to build with the following error:

The type ‘TInterface’ must be a reference type in order to use it as parameter ‘TService’ in the generic type or method ‘Castle.MicroKernel.Registration.ComponentRegistration’

public static class ContainerExtensions
{
    /// <summary>
    /// Sets the registration expectation on the mocked container.
    /// </summary>
    /// <typeparam name="TInterface">The type of the interface.</typeparam>
    /// <typeparam name="TImplementation">The type of the implementation.</typeparam>
    /// <param name="container">The container.</param>
    public static void SetRegistrationExpectation<TInterface, TImplementation>(this IWindsorContainer container) where TImplementation : TInterface
    {
        Predicate<IEnumerable<IRegistration>> pred = regs =>
        {
            var reg = regs.OfType<ComponentRegistration<TInterface>>().FirstOrDefault();
            return reg != null && reg.Implementation == typeof(TImplementation);
        };

        container
            .Expect(c => c.Register(null))
            .IgnoreArguments()
            .Constraints(Rhino.Mocks.Constraints.Is.Matching(pred))
            .Repeat.Once();
    }
}

So it would seem ComponentRegistration can no longer take an interface? Having looked at the documentation I am still unsure how to rectify?

Any pointers 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-06-07T03:13:28+00:00Added an answer on June 7, 2026 at 3:13 am

    Try to add where TInterface : class constraint to your method:

    public static void SetRegistrationExpectation<TInterface, TImplementation>(this IWindsorContainer container)
        where TInterface : class
        where TImplementation : TInterface
    

    It seems like ComponentRegistration generic constraints changed in 3.0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I inherited a moderately large sized code base that makes extensive use of mysql_fetch_assoc
I'm an asp.net newbie. I have inherited a base of asp.net mvc code and
I have inherited some HTML code and have been asked to align the two
I have the following code in specman that I inherited: some_method() is { var
I have inherited a DotNetNuke codebase and have come across areas that have included
I have inherited some code: Process p = new ProcessBuilder(/bin/chmod, 777, path).start(); p.waitFor(); Basically,
I have inherited some code (from zip file) from a developer and git initialzed,
Code which I have inherited keeps crashing out rather powerfully with the following error
I have inherited a classic ASP application and looking through the code I see
I have the following code (inherited from someone): <div class=feedback>&nbsp;</div> <form onsubmit=return false autocomplete=off>

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.