无法加载DLL'sni.dll'

编程入门 行业动态 更新时间:2024-10-26 07:24:07
本文介绍了无法加载DLL'sni.dll'-实体框架核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Visual Studio 2017的ASP.Net Core应用程序中使用Entity Framework Core时,间歇性地收到错误无法加载'sni.dll'.

奇怪的是,尽管我找到了一个临时修复程序:重新启动PC.

我不知道为什么错误不断发生,我也不知道变量可能是什么.有人可以阐明可能的原因吗?我会提供完整的堆栈跟踪,但是自从决定在此处发布以来就没有发生过,当下次发生时,我将确保对其进行更新.我可以肯定地知道(因为调试捕获了异常),当EF导致从db获取数据并将其转换为实体时,就会发生这种情况.

提前感谢您的任何建议.

-编辑 这仍在发生.设法记住要捕获堆栈跟踪:

发生System.DllNotFoundException HResult = 0x80131524 消息=无法加载DLL'sni.dll':指定的网络名称不再可用. (来自HRESULT的异常:0x80070040) 来源= 堆栈跟踪: 在System.Data.SqlClient.SNINativeMethodWrapper.UnmanagedIsTokenRestricted(IntPtr令牌,Boolean&isRestricted)中 在System.Data.Win32NativeMethods.IsTokenRestrictedWrapper(IntPtr令牌)处 在System.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrent() 在System.Data.ProviderBase.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory connectionFactory) 在System.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection owningObject,DbConnectionPoolGroup connectionPoolGroup) 在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重试,DbConnectionOptions userOptions) 在System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource 1 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操作,Func 2 verifySucceeded, TState state) at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3 1.MoveNext() 在Microsoft.EntityFrameworkCore.Query.QueryMethodProvider中.< _Include> d__30 1.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable 1源) 在Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<> c__DisplayClass20_0 1.<CompileQueryCore>b__0(QueryContext qc) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable 1源)

解决方案

添加nuget包System.Data.SqlClient v4.4.0为我解决了同样的问题.该问题并非特定于实体框架.这是由旧版本的SqlClient对API的依赖关系所引起的,该API在dotnet Core 2中不可用.

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.

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.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, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 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](Func2 operation, Func2 verifySucceeded, TState state) at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__31.MoveNext() at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_Include>d__301.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_01.<CompileQueryCore>b__0(QueryContext qc) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source)

解决方案

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'

本文发布于:2023-11-13 21:47:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585406.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   DLL   sni   dll

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!