2010-06-02 18 views
5

के लिए TypeLoadException का कारण बनता है मैं अपने महल विंडसर एक्सएमएल फ़ाइल में निम्न मानचित्रण जो कुछ समय के लिए ठीक है (अपरिवर्तित) काम किया है है:कैसल विंडसर उन्नयन सामान्य प्रकार

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

मैं http://www.castleproject.org/container/documentation/v1rc3/usersguide/genericssupport.html पर विंडसर प्रलेखन से मिला है।

जब से मैं विंडसर उन्नत बनाया है, अब मैं निम्न अपवाद कार्यावधि में मिलती है:

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));

मैं ASP.NET MVC 1.0, विजुअल स्टूडियो 2008 और महल विंडसर से http://sourceforge.net/projects/castleproject/files/InversionOfControl/2.1/Castle-Windsor-2.1.1.zip/download

डाउनलोड किया के रूप में उपयोग कर रहा हूँ कर सकते हैं किसी ने इस पर कोई प्रकाश डाला? मुझे यकीन है कि कैसल विंडसर का अपग्रेड इसके कारण हुआ है - यह उम्र के लिए अच्छी तरह से काम कर रहा है।

अद्यतन:
मैंने इसे अंत में स्वयं तय कर दिया। विवरण के लिए नीचे my answer देखें।

उत्तर

8

मैपिंग में सभी कक्षाओं/इंटरफेस की तुलना करके मुझे अंत में जवाब मिल गया।

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

... लेकिन इंटरफ़ेस है कि इसे लागू किया ही बाधा नहीं था:

public interface IBasicRepository<T> 
{ 

जवाब यह है कि BasicRepository के सामान्य प्रकार तर्क एक सामान्य बाधा के रूप में निम्नानुसार था

मैं मैच के लिए इंटरफ़ेस अद्यतन:

public interface IBasicRepository<T> 
    where T : class 
{ 

और अब everythi एनजी ठीक काम करता है।

उम्मीद है कि यह किसी की मदद करेगा। :)

संबंधित मुद्दे