错误Microsoft.Web.Infrastructure,版本= 1.0.0.0,文化=中立,PublicKeyToken = 31bf3856ad364e35

我有一个小型的Web应用程序。 这是工作正常,直到我在我的应用程序中添加了两个genericHandler。

我已经对http处理程序进行了以下更改

<system.web> <authentication mode="Forms" > <forms protection="All" timeout="720" defaultUrl="Default.aspx" loginUrl="Login.aspx" > </forms> </authentication> <authorization> <deny users="?"/> </authorization> <compilation debug="true" targetFramework="4.0" /> <httpHandlers> <!--Code Log Handler--> <add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory" /> <add verb="*" type="InfoDomeNewUI.Handler.SendOWA" path="SendOWA.ashx" /> <add verb="*" type="InfoDomeNewUI.Handler.SendSOS" path="SendSOS.ashx" /> </httpHandlers> <customErrors mode="Off"> <error statusCode="404" redirect="Templates/PageNotFound.html" /> </customErrors> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <handlers> <!--Code Log Handler--> <add name="LogHandler1" path="SendOWA.ashx" verb="*" type="InfoDomeNewUI.Handler.SendOWA"/> <!-- SMS SENDER--> <add name="SendSOS" path="SendSOS.ashx" verb="*" type="InfoDomeNewUI.Handler.SendSOS"/> </handlers> </system.webServer> Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 

我正在使用asp.net4.0和C#。 我没有使用MVC
在本地主机上工作正常。
但是,当我主持公布的代码,它给了我上面的错误。

堆栈跟踪:-

[FileNotFoundException:无法加载文件或程序集'Microsoft.Web.Infrastructure,版本= 1.0.0.0,文化=中立,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 系统找不到指定的文件。] System.Web.Http.WebHost.SuppressFormsAuthRedirectModule.Register()+0

[InvalidOperationException:预应用程序启动初始化方法启动typesSystem.Web.Http.WebHost.PreApplicationStartCode抛出一个exception,并显示以下错误消息:无法加载文件或程序集'Microsoft.Web.Infrastructure,版本= 1.0.0.0,文化=中立,PublicKeyToken = 31bf3856ad364e35“或其依赖之一。 系统找不到指定的文件..] System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods)+11708830 System.Web.Compilation.BuildManager.CallPreStartInitMethods()+465 System.Web.Hosting.HostingEnvironment.Initialize ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters,PolicyLevel policyLeve

[HttpException(0x80004005):预应用程序启动初始化方法启动typesSystem.Web.Http.WebHost.PreApplicationStartCode抛出一个exception,并显示以下错误消息:无法加载文件或程序集“Microsoft.Web.Infrastructure,版本= 1.0 .0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 系统找不到指定的文件..] System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+11697760 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文)+141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext上下文) 4866485

看来, Microsoft.Web.Infrastructure.dll没有安装在GAC中,即使.net(4.0或4.5或其他)在Windows Server上成功安装。 在本地主机上(通常是Windows客户端),似乎在安装工具/平台(Visual Studio等)时正在GAC中。

作为一种可能的修复方法,请尝试以下操作:

  1. 在程序包pipe理器控制台中运行以下命令。 (如果您使用的是Visual Studio,可以通过菜单选项“Tools – > Library Package Manager – > Package Manager Console 🙂

     PM> Install-Package Microsoft.Web.Infrastructure 

    如果安装成功,您将看到以下消息。

     Successfully installed 'Microsoft.Web.Infrastructure 1.0.0.0'. Successfully added 'Microsoft.Web.Infrastructure 1.0.0.0' to Web. 
  2. 您会注意到Microsoft.Web.Infrastructure.dll现在已经添加为参考(可以在Solution Explorer中的项目的参考文件夹中看到)

  3. 如果你看看这个参考的属性,你会注意到默认情况下“ 复制本地 ”已经被设置为“ ”。

  4. 现在,当您“发布”您的项目时,将部署Microsoft.Web.Infrastructure.dll

我通过WPI安装了MVC4,它帮助了我。

我有同样的问题。 当我尝试接受的答案(rockyb)时,我得到了这个包已经安装并分配给我的项目的消息。 当我检查参考列表,但是没有被引用。

Microsoft.Web.Infrastructure安装在我的解决scheme的包文件夹中。 我没有使用NuGet来添加包,而是使用了Add Reference选项。 在popup窗口的左侧,我select了浏览,然后按下窗口底部的浏览button。 我导航到我的解决scheme所在的文件夹下的软件包文件夹,然后钻取到… \ mysolution \ packages \ Microsoft.Web.Infrastructure.1.0.0.0 \ lib \ net40并单击Microsoft.Web.Infrastructure .dll文件。 点击确定后,包出现在我的参考列表中。 我使用Web部署包选项部署我的网站,一切工作。

我发现了这个问题。 我错误地添加了一个类(.cs)文件,而不是添加了一个Web API Controller类,它在我的解决scheme中添加了一个configuration文件。 该configuration文件正在寻找提到的DLL(Microsoft.Web.Infrastructure 1.0.0.0)。 它工作时,我删除该文件,清理应用程序,然后发布。

为什么不手动将Microsoft.Web.Infrastructure.dll文件复制到服务器BIN文件夹。 这适用于。 我的项目是VS2010网站。

这个文件可以位于:

C:\ Program Files(x86)\ Microsoft ASP.NET \ ASP.NET MVC 4 \ Packages \ Microsoft.Web.Infrastructure.1.0.0.0 \ lib \ net40

只需复制并粘贴到BIN文件夹。

如果你还没有,你可能需要在web.config中包含这个

 <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </assemblies> </compilation> 

参考: http : //thedeveloperblog.com/

通过Nuget-Package Manager安装Microsoft.Web.Infrastructure之后

 PM> Install-Package Microsoft.Web.Infrastructure 

从您的Web应用程序的Nuget-Package文件夹中手动复制Microsoft.Web.Infrastructure.dll ,然后将其粘贴到Web服务器上部署的Web应用程序的bin文件夹中。

包\ Microsoft.Web.Infrastructure.1.0.0.0 \ LIB \ net40 \ Microsoft.Web.Infrastructure.dll

它为我工作。

Update-Package -reinstall Microsoft.Web.Infrastructure没有为我工作,因为我不断收到错误,它已经安装。

我不得不导航到软件包文件夹中的Microsoft.Web.Infrastructure.1.0.0.0文件夹,并手动删除该文件夹。

这样做后,运行Install-Package Microsoft.Web.Infrastructure安装它。

注意: CopyLocal自动设置为true。

我有同样的问题,并且“Microsoft.Web.Infrastructure.dll”似乎已经丢失。 我已经尝试了几个build议,并安装MVC的等等,没有任何帮助。 解决scheme是安装“Web Services Enhancements(WSE)1.0 SP1 for Microsoft .NET”,其中包括Microsoft.Web.Infrastructure.dll。 url为: http : //www.microsoft.com/en-gb/download/details.aspx?id=4065

我有同样的问题。 我尝试安装Visual Studio 2010 SP1,但它没有奏效。

最后我从同事那里得到Microsoft.Web.Infrastructure.dll。 你可以find你的朋友个人电脑的项目是完美的工作。 尝试search到Temp / Temporary ASP.NET文件的DLL。 使用%temp%进入运行窗口。

进入你的电脑后,只需添加引用到您的项目,它将工作。

重新发布网站为我解决了这个问题。