简体   繁体   English

无法加载 DLL 'sni.dll' 或其依赖项之一:找不到指定的模块

[英]Unable to load DLL 'sni.dll' or one of its dependencies: The specified module could not be found

Im running UI tests on my self hosted agent, when trying to restore the database i get the following error message:我在我的自托管代理上运行 UI 测试,当尝试恢复数据库时,我收到以下错误消息:

[ERROR] The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception. -> The type initializer for 'System.Data.SqlClient.SNILoadHandle' threw an exception. -> Unable to load DLL 'sni.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

These are my Dependensies这些是我的依赖

    <PackageReference Include="Appium.WebDriver" Version="4.3.1" />
    <PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
    <PackageReference Include="Microsoft.VisualStudio.TestPlatform" Version="14.0.0" />
    <PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.5" />
    <PackageReference Include="SpecRun.SpecFlow" Version="3.9.7" />
    <PackageReference Include="FluentAssertions" Version="5.10.3" />
    <PackageReference Include="System.Data.SqlClient" Version="4.8.2" />

My buildpipline is working fine and looks like that:我的 buildpipline 工作正常,看起来像这样: 在此处输入图片说明

And when running dotnet --info on the agent machine I get the following output在代理机器上运行dotnet --info时,我得到以下输出

.NET SDK (reflecting any global.json):
 Version:   5.0.301
 Commit:    ef17233f86

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.301\

Host (useful for support):
  Version: 5.0.7
  Commit:  556582d964

.NET SDKs installed:
  5.0.301 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

This is my release Pipline which runs the tests这是我运行测试的发布管道

在此处输入图片说明

将 Microsoft.Data.SqlClient.Sni.xx.dll 复制到 bin 文件夹

If you are using Azure Piplines I would sugsenst using a powershell task to restore your database.如果您使用的是 Azure Piplines,我建议您使用 powershell 任务来恢复您的数据库。 I did it like this:我是这样做的:

First install the SQL Server module on your agents machine with this command:首先使用以下命令在您的代理计算机上安装 SQL Server 模块:

Install-Module -Name SqlServer

than add a Powershell task to your pipline and select inline and than you can run your SQL statement like this:将 Powershell 任务添加到您的管道并选择内联,然后您可以像这样运行 SQL 语句:

$sql = @"
USE [master]
ALTER DATABASE[TEST_DATABASE] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE[TEST_DATABASE] FROM DISK = 'D:\Public\TEST_DATABASE.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 5
ALTER DATABASE[TEST_DATABASE] SET MULTI_USER
"@

Invoke-Sqlcmd -Query $sql -ServerInstance "SERV\TESTING" –Username "dev" –Password "12345678"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集“ XXXX.dll”或其依赖项之一。 指定的模块无法找到 - Could not load file or assembly 'XXXX.dll' or one of its dependencies. The specified module could not be found 无法加载文件或程序集“ idrsnet15.dll”或其依赖项之一。 指定的模块无法找到 - Could not load file or assembly 'idrsnet15.dll' or one of its dependencies. The specified module could not be found 无法加载文件或程序集“ClearScriptV8-32.DLL”或其依赖项之一。 指定的模块无法找到 - Could not load file or assembly 'ClearScriptV8-32.DLL' or one of its dependencies. The specified module could not be found 无法加载文件或程序集“CopyModules.dll”或其依赖项之一。指定的模块无法找到 - Could not load file or assembly 'CopyModules.dll' or one of its dependencies. The specified module could not be found 无法加载文件或程序集“xxx.dll”或其依赖项之一。 指定的模块无法找到 - Could not load file or assembly 'xxx.dll' or one of its dependencies. The specified module could not be found 无法加载 SNI.dll - Failed to load SNI.dll 无法加载 DLL 'sni.dll' - Entity Framework Core - Unable to load DLL 'sni.dll' - Entity Framework Core 无法加载DLL:找不到指定的模块 - Unable to load DLL: The specified module could not be found 无法加载DLL&#39;mydll.dll&#39;:找不到指定的模块 - Unable to load DLL ' mydll.dll': The specified module could not be found 无法加载DLL&#39;UNRAR.DLL&#39;:找不到指定的模块 - Unable to load DLL 'UNRAR.DLL': The specified module could not be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM