2015-12-15 108 views
2

我的Web-Api項目在我的本地機器上工作得很好,但是在將它部署到我的文件系統並將其複製到Windows Server 2008 - IIS7後,我嘗試訪問RESTful-Service時獲取此異常。ASP.NET Web-Api本地工作,但不能在IIS7上部署後

Could not load file or assembly 'System.Web.Http, Version=5.2.3.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) 

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.IO.FileLoadException: Could not load file or assembly 'System.Web.Http, Version=5.2.3.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) 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded. 


WRN: Assembly binding logging is turned OFF. 
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. 
Note: There is some performance penalty associated with assembly bind failure logging. 
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. 

Stack Trace: 


[FileLoadException: Could not load file or assembly 'System.Web.Http, Version=5.2.3.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)] 
    HappyOrder.WebApi.WebApiApplication.Application_Start() +0 

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http, Version=5.2.3.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)] 
    System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12601933 
    System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175 
    System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304 
    System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404 
    System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475 

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http, Version=5.2.3.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)] 
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12618980 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12458597 

這發生後,我安裝的NuGet-包Microsoft.AspNet.WebApi.Cors,首先它甚至沒有在本地工作,但後來我設法得到它與的NuGet-軟件包管理器突擊隊「更新-包」工作。

+1

你或許應該檢查的.NET版本安裝在服務器和ASP.Net版本。這絕對是IIS應用程序池中的框架設置 – Thanigainathan

+1

您是如何部署它的?你確定你的'bin'目錄包含列出的程序集嗎? – Kamo

+0

@Thanigainathan:服務器上的.Net版本是4.5.2,asp.net目標版本是4.5,asp.net版本是5.2.3.0 –

回答

0

請重新安裝ASP.Net的服務器使用此命令

ASPNET_REGIIS.EXE -i

這將設置ASP.net權利,使其工作

+0

如果我不想更改,應該使用什麼命令發佈服務器的所有ASP.NET版本? 我不是一個人在這臺機器上工作。 –

+0

我們可以嘗試其他選項。爲這個DLL做了複製本地真實? – Thanigainathan

相關問題