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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:53:27+00:00 2026-05-15T03:53:27+00:00

I have the following mapping in my Castle Windsor xml file which has worked

  • 0

I have the following mapping in my Castle Windsor xml file which has worked okay (unchanged) for some time:

<component id="defaultBasicRepository"
           service="MyApp.Models.Repositories.IBasicRepository`1, MyApp.Models"
           type="MyApp.Models.Repositories.Linq.BasicRepository`1, MyApp.Models"
           lifestyle="perWebRequest"/>

I got this from the Windsor documentation at http://www.castleproject.org/container/documentation/v1rc3/usersguide/genericssupport.html.

Since I upgraded Windsor, I now get the following exception at runtime:

Description: An unhandled exception
occurred during the execution of the
current web request. Please review the
stack trace for more information about
the error and where it originated in
the code.

Exception Details:
System.TypeLoadException:
GenericArguments[0], ‘T’, on ‘MyApp.Models.Repositories.Linq.BasicRepository`1[TEntity]’
violates the constraint of type parameter ‘TEntity’.

Source Error:

Line 44: public static void ConfigureIoC()
Line 45: {
Line 46: var windsor = new WindsorContainer(“Windsor.xml”);
Line 47:
Line 48: ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(windsor));

I’m using ASP.NET MVC 1.0, Visual Studio 2008 and Castle Windsor as downloaded from http://sourceforge.net/projects/castleproject/files/InversionOfControl/2.1/Castle-Windsor-2.1.1.zip/download

Can anyone shed any light on this? I’m sure the upgrade of Castle Windsor is what caused it – it’s been working well for ages.

UPDATE:
I fixed it myself in the end. See my answer below for details.

  • 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-15T03:53:28+00:00Added an answer on May 15, 2026 at 3:53 am

    I found the answer for myself in the end, by comparing all the classes/interfaces in the mapping.

    The answer was that the BasicRepository‘s generic type argument had a generic constraint as follows:

    public class BasicRepository<TEntity> : IBasicRepository<TEntity>
        where TEntity : class
    {
    

    …but the interface that it implemented didn’t have the same constraint:

    public interface IBasicRepository<T>
    {
    

    I updated the interface to match:

    public interface IBasicRepository<T>
        where T : class
    {
    

    and now everything works fine.

    Hope this helps someone. 🙂

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

Sidebar

Related Questions

I have the following component mapping in Windsor xml: <component id=dataSession.DbConnection service=System.Data.IDbConnection, System.Data, Version=2.0.0.0,
I have the following Hibernate Mapping, which has to be mapped using the Table
I have the following mapping file: <?xml version=1.0 encoding=utf-8 ?> <hibernate-mapping xmlns=urn:nhibernate-mapping-2.2 assembly=Project1.Accounts namespace=Project1.Core.Domain>
I have the following mapping for the birth date in the hbm.xml file <property
NHibernate is driving me 'Nuts'!!! I have the following mapping. Which returns this error
I have the following mapping: <?xml version='1.0' encoding='utf-8'?> <hibernate-mapping assembly='Core' namespace='Core.Models' xmlns='urn:nhibernate-mapping-2.2'> <class name='Basket'>
I have created the following mapping in my vimrc file: noremap <C-p> ! firefox
I have following Hibernate 3 mapping for User class: <class name=org.test.User table=users> ... some
I have the following mapping for a Relation in Castle AR [BelongsTo(EVENT_ID, Lazy =
I have the following mapping: <hibernate-mapping package=server.modules.stats.data> <class name=User table=user> <id name=id> <generator class=native></generator>

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.