2014-01-30 64 views
1

我曾在一個Asp.Net MVC4應用我的個人桌面和Asp.Net託管問題:無法加載文件或程序集「System.Web.Http,版本= 4.0.0.0,文化=中性公鑰= 31bf3856ad364e35」

Server Error in '/' Application. 
-------------------------------------------------------------------------------- 


Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 
    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.FileNotFoundException: Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 

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=4.0.0.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: 



[FileNotFoundException: Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] 
    MvcApplication1.MvcApplication.Application_Start() +0 

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] 
    System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12864673 
    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=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] 
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601 

我可以知道我ID:試圖通過使用正常的部署過程和最後當我試圖瀏覽它遠程登錄到它給它舉辦成的Windows Server 2012和IIS8如下丟給我一個服務器錯誤一個錯誤

+0

你有沒有配置的應用程序池運行的.Net V4.0? – Carl

+0

是的,我沒有配置 – DoIt

回答

0

簡單地說,還沒有部署必要的程序集的引用在主機正常工作!它試圖搜索,也許在主機提供商系統,而無法訪問!按照these steps的規定,確保您已部署所需的文件。

編輯: 因此,在該選項(添加部署的依賴)在Visual Studio 2010(和Visual Studio 2010 SP1)仍然存在,它是建立在NuGet包管理器旁邊的Visual Studio 2012,使所有需要的組件會自動部署。

+0

當我在我的VS 2012項目右側點擊,我沒有找到「添加部署的依賴關係」選項 – DoIt

+0

你@Dayakar我更新了答案。 –

+0

謝謝你,但現在所有必需的組件自動部署,那麼我可以知道爲什麼它仍然拋出異常 – DoIt

0

在這種情況下缺少的特定程序集是Web API 2.1 WebHost(或2.2現在)。只需將Nuget包控制檯添加到您的項目中,然後重新構建即可。

0

嘗試在Web API 2.1虛擬主機提供商加入到使用NuGet包管理器中的項目,然後重新生成,發佈和部署IIS。

相關問題