我正在使用最新版本的Azure函数3.0.1和.net core 3.1。 (以下问题看起来很熟悉,但并没有帮助我,因此创建了一个新的Azure functions runtime exception, the type initializer for system data sqlclient excetion, Unable to load DLL 'sni.dll')
另一个重要信息是我正在使用NHibernate,并且在执行cfg.BuildSessionFactory()时出现此错误;命令。
运行时错误是:
在启动操作'3756a542-87f8-43dd-a977-fbf87c7597d1'期间发生主机错误。[12/11/2019 5:17:42 AM] System.Data.SqlClient:'System.Data.SqlClient.TdsParser'的类型初始值设定项引发了异常。 System.Data.SqlClient:'System.Data.SqlClient.SNILoadHandle'的类型初始值设定项引发了异常。 System.Data.SqlClient:无法加载DLL“ sni.dll”或其依赖项之一:找不到指定的模块。 (0x8007007E)。
这是.csproj文件的一部分。
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.1" />
</ItemGroup>
此外,作为解决方案,添加了以下软件包,而不是system.data.sqlclient,但它们都给出相同的错误。
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.0" />
我已经跟踪了此链接https://dev.to/azure/develop-azure-functions-using-net-core-3-0-gcm中的所有内容,以建立一个新项目。
您是否尝试添加对System.Data.SqlClient v4.4.0的nuget引用。在Resolution to missing sni.dll
中对此进行了描述