我在溫莎城堡的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。