Asp.Net MVC 5和Hottowel 2.01 / Breeze - 無法加載文件或程序集'System.Web.Http,Version = 4.0.0.0,...或其依賴項之一

[英]Asp.Net MVC 5 and Hottowel 2.01/Breeze - Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, … or one of its dependencies


I created a new Asp.net MVC 5 project using VS 2013 and then added HotTowel 2.0.1 (http://www.nuget.org/packages/HotTowel/). The site works. However, the webapi with breeze controller get the following error when I try to get the WebApi controller of Events. The breeze version is 1.4.2.

我使用VS 2013創建了一個新的Asp.net MVC 5項目,然后添加了HotTowel 2.0.1(http://www.nuget.org/packages/HotTowel/)。該網站有效。但是,當我嘗試獲取事件的WebApi控制器時,帶有breeze控制器的webapi會出現以下錯誤。微風版本是1.4.2。

The controller code is

控制器代碼是

[BreezeController]
public class BreezeController : ApiController
{
    readonly EFContextProvider<ApplicationDbContext> _contextProvider = new EFContextProvider<ApplicationDbContext>();

    [HttpGet]
    public string Metadata()
    {
        return _contextProvider.Metadata();
    }

    [HttpGet]
    public IQueryable<Event> Events()
    {
        return _contextProvider.Context.Events;
    }
}

The error message is

錯誤消息是

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
</ExceptionMessage>
<ExceptionType>System.IO.FileLoadException</ExceptionType>
<StackTrace>
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) at System.RuntimeType.GetCustomAttributes(Boolean inherit) at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type) at System.Web.Http.Controllers.HttpControllerDescriptor.Initialize() at System.Web.Http.Controllers.HttpControllerDescriptor..ctor(HttpConfiguration configuration, String controllerName, Type controllerType) at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.InitializeControllerInfoCache() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at System.Lazy`1.get_Value() at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.SelectController(HttpRequestMessage request) at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__0.MoveNext()
</StackTrace>
</Error>

1 个解决方案

#1


2  

Most likely your code reference system.web.http version 4.0.0.0, while your project is referencing version 5. You could either install version 4, or upgrade your code to use version 5.

很可能您的代碼引用system.web.http版本4.0.0.0,而您的項目引用版本5.您可以安裝版本4,也可以升級代碼以使用版本5。

If the code that refers to version 4 is in a third party lib (i.e Breeze) then you will have to get a new version from them, or install the old version (4) of the system.web.http lib.

如果引用版本4的代碼在第三方lib(即Breeze)中,則必須從它們獲取新版本,或者安裝system.web.http lib的舊版本(4)。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/11/20/7212498b24501b00a13c2059cee357dc.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com