MSFT 声称 .NET 4.5 向后兼容 .NET 4。我继续安装了 .NET 4.5 和 VS 11,然后创建了一个新的 ASP.NET MVC 4 Web API 项目。当我将 Castle.ActiveRecord.dll(版本 3.0.0.0)引用到我的 Web API 项目中时,每个控制器操作都会生成此错误:
[FileNotFoundException: Could not load file or assembly 'Lucene.Net, Version=2.3.1.3, Culture=neutral, PublicKeyToken=45b1dda587cdc860' or one of its dependencies. The system cannot find the file specified.]
System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) +0
System.Reflection.RuntimeAssembly.GetExportedTypes() +49
System.Web.Http.Dispatcher.HttpControllerTypeCacheUtil.FilterTypesInAssemblies(IBuildManager buildManager, Predicate`1 predicate) +210
System.Web.Http.Dispatcher.HttpControllerTypeCache.InitializeCache() +119
System.Web.Http.Dispatcher.HttpControllerTypeCache..ctor(HttpConfiguration configuration) +69
System.Web.Http.Services.DefaultServiceResolver.<.ctor>b__0(HttpConfiguration config) +241
System.Web.Http.Services.DefaultServiceResolver.GetService(Type t) +80
System.Web.Http.DependencyResolverExtensions.GetService(DependencyResolver resolver) +201
System.Web.Http.DependencyResolverExtensions.GetServiceOrThrow(DependencyResolver resolver) +60
System.Web.Http.Dispatcher.HttpControllerDispatcher..ctor(HttpConfiguration configuration) +65
System.Web.Http.GlobalConfiguration.<.cctor>b__1() +64
System.Lazy`1.CreateValue() +13589652
System.Lazy`1.LazyInitValue() +476
System.Web.Http.WebHost.HttpControllerHandler.<.cctor>b__b() +53
System.Lazy`1.CreateValue() +455
System.Lazy`1.get_Value() +13590694
System.Web.Http.WebHost.HttpControllerHandler.BeginProcessRequest(HttpContextBase httpContextBase, AsyncCallback callback, Object state) +224
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +444
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +354
这很有趣,因为从我读到的。版本 2.3.1.3 是 Lucene (java) 版本,而不是 Lucene.Net 版本。为了确定,我检查了 NuGet,它没有可用于 Lucene.Net 的版本 2.3.1.3。
是什么赋予了?我很想运行新的 ASP.NET MVC 4 Web API 项目,因为它融合了我对 ASP.NET MVC 和 WCF Web API 的喜爱。关于如何解决这个问题的任何想法?