簡體   English   中英

無法加載文件或程序集“Microsoft.SqlServer.Management.RegisteredServers,版本=15.2.0.0,文化=中性,PublicKeyToken=89845dcd8080cc91”

[英]Could not load file or assembly 'Microsoft.SqlServer.Management.RegisteredServers, Version=15.2.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'

根據我在Unable to create RegisteredServer in Microsoft.SqlServer.Management.RegisteredServers 中的回答,我安裝了

Microsoft.SqlServer.SqlManagementObjects
Microsoft.SqlServer.Smo
System.Security.Cryptography.ProtectedData

它適用於基於.Net Core 2.0 的Consol Application 和基於.Net Standard 2.0 的ClassLibrary:

在此處輸入圖像描述 在此處輸入圖像描述

現在我在我的主要 C# 解決方案中使用它們,其中 Web 應用程序基於.Net Framework 4.7.1 和 Class 庫基於.Net Standard 2.0:

在此處輸入圖像描述 在此處輸入圖像描述

我收到了這個錯誤:

Could not load file or assembly 'Microsoft.SqlServer.Management.RegisteredServers, Version=15.2.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

這是細節:

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.SqlServer.Management.RegisteredServers, Version=15.2.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
 (Fully-specified)
LOG: Appbase = file:///C:/Code/Platform/Platform.Web/
LOG: Initial PrivatePath = C:\Code\Platform\Platform.Web\bin
Calling assembly : Application.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Code\Platform\Platform.Web\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.SqlServer.Management.RegisteredServers, Version=15.2.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/cd41b801/927eac2d/Microsoft.SqlServer.Management.RegisteredServers.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/cd41b801/927eac2d/Microsoft.SqlServer.Management.RegisteredServers/Microsoft.SqlServer.Management.RegisteredServers.DLL.
LOG: Attempting download of new URL file:///C:/Code/Platform/Platform.Web/bin/Microsoft.SqlServer.Management.RegisteredServers.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

我嘗試了不同的解決方案,例如定位程序集的清單定義與程序集引用不匹配,但它們不起作用

最后,解決方案的組合起作用:

1)刪除objbin文件夾

2) 更新 web.config 文件中的引用,然后從 NuGet Package 管理器控制台運行此命令以添加新綁定:

Get-Project -All | Add-BindingRedirect

3)刪除C:\WINDOWS\Microsoft.NET\Framework\~\Temporary ASP.NET Files\ directory

4) 在 web.config 中添加dependentAssembly

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.SqlServer.Management.RegisteredServers" publicKeyToken="89845dcd8080cc91" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-15.100.0.0" newVersion="15.100.0.0" />
  </dependentAssembly>

它應該與 project.cspj 相同:

 <Reference Include="Microsoft.SqlServer.Management.RegisteredServers, Version=15.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.SqlServer.SqlManagementObjects.150.18208.0\lib\net45\Microsoft.SqlServer.Management.RegisteredServers.dll</HintPath>
</Reference>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 無法加載文件或程序集 'Microsoft.SqlServer.Types,Version=15.0.0.0,Culture Neutral,PublicKeyToken=89845dcd8080cc91' 無法加載文件或程序集“Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=myKey”或其依賴項之一。 FileLoadException:無法加載文件或程序集&#39;Microsoft.Practices.ObjectBuilder,版本= 1.0.51205.0,區域性=中性,PublicKeyToken =空&#39; 無法加載文件或程序集“Esri.ArcGISRuntime,版本=100.13.0.0,文化=中性,PublicKeyToken=8fc3cc631e44ad86” 無法加載文件或程序集“EntityFramework.SqlServer,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089” 無法加載文件或程序集“Microsoft.Bcl.AsyncInterfaces,Version=1.0.0.0,Culture=neutral,PublicKeyToken=XX”或其依賴項之一 無法加載文件或程序集 'Microsoft.Extensions.DependencyModel,Version=5.0.0.0,Culture=neutral,PublicKeyToken=adb9793829ddae60 無法加載文件或程序集“Microsoft.Owin,版本=3.0.1.0,文化=中性,PublicKeyToken=31bf3856ad364e35” System.IO.FileNotFoundException:無法加載文件或程序集“Microsoft.ReportViewer.Common,版本=12.0.0.0,文化=中性,PublicKeyToken= 無法加載文件或程序集“Microsoft.Owin,版本=2.1.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM