我有一个小型网络应用程序。在我在应用程序中添加两个 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.Infrastruct,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。该系统找不到指定的文件。]
System.Web.Http.WebHost.SuppressFormsAuthRedirectModule.Register() +0
[InvalidOperationException:预应用程序启动初始化方法 Start on type System.Web.Http.WebHost.PreApplicationStartCode 引发异常,并显示以下错误消息:无法加载文件或程序集“Microsoft.Web.Infrastruct,版本 = 1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 或其依赖项之一。该系统找不到指定的文件..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 方法)+11708830
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +465
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters 托管参数,PolicyLevel 策略Leve
[HttpException (0x80004005):类型 System.Web.Http.WebHost.PreApplicationStartCode 上的预应用程序启动初始化方法引发异常,并显示以下错误消息:无法加载文件或程序集“Microsoft.Web.Infrastruct,版本=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.Infrastruct.dll即使 .net(4.0 或 4.5 或其他)已成功安装在 Windows Server 上,也不会安装在 GAC 中。在本地主机(通常是 Windows 客户端)上,安装工具/平台(Visual Studio 等)时,它似乎位于 GAC 中。
作为一种可能的修复方法,请尝试以下操作:
-
在包管理器控制台中运行以下命令。 (如果您使用的是 Visual Studio,可以通过菜单选项“工具 --> 库包管理器 --> 包管理器控制台:)
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.
你会注意到Microsoft.Web.Infrastruct.dll现已添加为参考(可以在解决方案资源管理器中项目的参考文件夹中看到)
如果您查看此引用的属性,您会注意到“复制本地“已设置为”True“ 默认情况下。
现在,当您“发布”您的项目时,Microsoft.Web.Infrastruct.dll将被部署。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)