ASP.NET Core部署IIS报错:找不到System.DirectoryServices.Protocols程序集
针对ASP.NET Core部署IIS后找不到System.DirectoryServices.Protocols的解决方案
1. 添加程序集绑定重定向
在项目根目录的web.config中添加runtime绑定配置,强制IIS加载指定版本的程序集:
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.DirectoryServices.Protocols" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
2. 验证发布时的依赖复制设置
- 右键项目 → 管理NuGet程序包,找到
System.DirectoryServices.Protocols,确保其“复制本地”属性为True(在解决方案资源管理器中右键该程序集→属性查看)。 - 发布时选择框架依赖模式,或者在独立部署模式下,检查发布输出目录中是否确实包含该程序集的8.0.0版本。
3. 检查IIS应用池配置
- 确认应用程序池的**.NET CLR版本**设置为
无托管代码,ASP.NET Core应用不依赖传统IIS托管运行时。 - 检查应用池的运行身份,确保该账号对网站部署目录有读取权限,避免因权限不足导致无法加载程序集。
4. 清理并重新构建发布
执行以下命令清理旧的构建文件,重新还原依赖并发布:
dotnet clean dotnet restore --force dotnet publish -c Release --no-restore
5. 手动注册到全局程序集缓存(备选方案)
如果上述方法都无效,可尝试将程序集注册到GAC:
- 找到发布目录中的
System.DirectoryServices.Protocols.dll - 以管理员身份打开命令提示符,执行:
gacutil /i "C:\path\to\your\publish\dir\System.DirectoryServices.Protocols.dll"
内容的提问来源于stack exchange,提问作者Chance
相关产品推荐
相关产品推荐

