我在温莎城堡的XML文件下面的映射已经有一段时间效果不错(不变):温莎城堡升级导致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,Visual Studio 2008和温莎城堡从http://sourceforge.net/projects/castleproject/files/InversionOfControl/2.1/Castle-Windsor-2.1.1.zip/download
能下载有人对此有何看法?我确信温莎城堡的升级是造成它的原因 - 它已经运行良好很多年了。
UPDATE:
我在最后自己修复了它。详情请参阅下面的my answer。