Unable to load DLL #39;sni.dll#39; - Entity Framework Core(无法加载 DLL sni.dll - 实体框架核心)
问题描述
在 Visual Studio 2017 上的 ASP.Net Core 应用程序中使用 Entity Framework Core 时,我间歇性地收到错误无法加载 'sni.dll'.
When using Entity Framework Core in an ASP.Net Core application on Visual Studio 2017 I intermittently get the error "Unable to load 'sni.dll'.
奇怪的是,我找到了一个临时解决方法:重新启动我的电脑.
Strangely though I have found a temporary fix: restarting my PC.
我不知道为什么错误不断发生,我不知道变量可能是什么.任何人都可以阐明可能的原因吗?我会提供完整的堆栈跟踪,但自从决定在这里发帖以来就没有发生过,下次发生时我一定会更新它.我肯定知道(因为调试捕获异常)当 EF 有理由从数据库获取数据并转换为实体时会发生这种情况.
I don't know why the error keeps happening, I don't know what the variable could be. Could anyone shed light on the possible cause? I would offer a full stack trace but it hasn't happened since deciding to post on here, when it next happens I'll be sure to update this. I know for certain though (as the debug catches the exception) that it happens when EF has cause to get data from the db and transform to entities.
提前感谢您的任何建议.
Thanks in advance for any suggestions.
--编辑这仍在发生.设法记住捕获堆栈跟踪:
--EDIT This is still happening. Managed to remember to capture the stack trace:
发生 System.DllNotFoundExceptionH结果=0x80131524消息=无法加载 DLL 'sni.dll':指定的网络名称不再可用.(来自 HRESULT 的异常:0x80070040)来源=堆栈跟踪:在 System.Data.SqlClient.SNINativeMethodWrapper.UnmanagedIsTokenRestricted(IntPtr 令牌,布尔和 isRestricted)在 System.Data.Win32NativeMethods.IsTokenRestrictedWrapper(IntPtr 令牌)在 System.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrent()在 System.Data.ProviderBase.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory 连接工厂)在 System.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection owningObject,DbConnectionPoolGroup connectionPoolGroup)在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource1 重试,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal& 连接)在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 重试, DbConnectionOptions userOptions)在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 重试)在 System.Data.SqlClient.SqlConnection.Open()在 Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open()在 Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(布尔缓冲区)在 Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func
2 操作,Func2 verifySucceeded,TState 状态)在 Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3
1.MoveNext()在 Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_Include>d__301.MoveNext()在 System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1 源)在 Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_01.<CompileQueryCore>b__0(QueryContext qc)在 System.Linq.Queryable.FirstOrDefault[TSource](IQueryable
1 源)
System.DllNotFoundException occurred HResult=0x80131524 Message=Unable to load DLL 'sni.dll': The specified network name is no longer available. (Exception from HRESULT: 0x80070040) Source= StackTrace: at System.Data.SqlClient.SNINativeMethodWrapper.UnmanagedIsTokenRestricted(IntPtr token, Boolean& isRestricted) at System.Data.Win32NativeMethods.IsTokenRestrictedWrapper(IntPtr token) at System.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrent() at System.Data.ProviderBase.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory connectionFactory) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection owningObject, DbConnectionPoolGroup connectionPoolGroup) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.Open() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open() at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func
2 operation, Func2 verifySucceeded, TState state) at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3
1.MoveNext() at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_Include>d__301.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1 source) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_01.<CompileQueryCore>b__0(QueryContext qc) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable
1 source)
推荐答案
添加 nuget 包 System.Data.SqlClient v4.4.0 为我解决了同样的问题.该问题并非特定于实体框架.这是由于旧版本的 SqlClient 依赖于 dotnet Core 2 中不可用的 API.
Adding nuget package System.Data.SqlClient v4.4.0 solved the same problem for me. The problem is not specific to Entity Framework. It is caused by older version of SqlClient dependency on APIs not available in dotnet Core 2.
这篇关于无法加载 DLL 'sni.dll' - 实体框架核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法加载 DLL 'sni.dll' - 实体框架核心
基础教程推荐
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- SSE 浮点算术是否可重现? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01