当尝试获取当前计算机上的应用程序池时,我遇到了一个奇怪的问题。看起来,当安装 IISExpress 时,Microsoft 代码除了完整的 IIS 之外还想检查 IISExpress。 IISExpress 对每个用户使用单独的 applicationHost 文件。我不确定这个调用是否需要它检查所有这些,或者只是检查当前用户的那些。无论如何,它都没有在“C:\Windows\system32\config\systemprofile\”目录中找到它要查找的内容。对于执行此代码的应用程序池所运行的用户,它应该转到 %userprofile% 或“C:\Users\Administrator\”。
有谁知道这个 systemprofile 目录是如何来自的?
Exception:-
System.IO.DirectoryNotFoundException: Filename: \\?\C:\Windows\system32\config\systemprofile\Documents\IISExpress\config\applicationHost.config
Error: Cannot read configuration file
at Microsoft.Web.Administration.Interop.AppHostWritableAdminManager.GetAdminSection(String bstrSectionName, String bstrSectionPath)
at Microsoft.Web.Administration.Configuration.GetSectionInternal(ConfigurationSection section, String sectionPath, String locationPath)
at Microsoft.Web.Administration.ServerManager.get_ApplicationPoolsSection()
at Microsoft.Web.Administration.ServerManager.get_ApplicationPools()
at CustomCode.Classes.IIsApplicationPool.GetApplicationPool(String iisWebSitePath, String poolName)
我强烈建议停止使用 IIS 附带的对 Microsoft.Web.Administration 的本地引用(即使它位于 GAC 中)。这是因为它有一个非常具体的版本号(即 7.0.0.0),并且该版本可能会在 Windows 的未来版本中发生变化,这会带来伤害。
相反,检查 nuget 包:Microsoft.Web.Administration
(https://www.nuget.org/packages/Microsoft.Web.Administration)。这基本上使得您可以对 IIS 依赖项进行私有部署。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)