entity-framework – 将ASP.NET Core EF发布到Azure无法加载DLL
发布时间:2020-12-16 06:40:11 所属栏目:asp.Net 来源:网络整理
导读:使用EF将ASP.NET Core应用程序发布到Azure Web App时,在连接SQL Server时会出现此错误: info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1] Executing action method SearchDocumentsWebApp.Controllers.SearchApiController.SearchByTop
使用EF将ASP.NET Core应用程序发布到Azure Web App时,在连接SQL Server时会出现此错误:
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1] Executing action method SearchDocumentsWebApp.Controllers.SearchApiController.SearchByTopic (SearchDocumentsWebApp) with arguments (info) - ModelState is Valid warn: Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory[8] The LINQ expression '[e].Id.Equals(__email_0,CurrentCultureIgnoreCase)' could not be translated and will be evaluated locally. To configure this warning use the DbContextOptionsBuilder.ConfigureWarnings API (event id 'RelationalEventId.QueryClientEvaluationWarning'). ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider. warn: Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory[8] The LINQ expression 'SingleOrDefault()' could not be translated and will be evaluated locally. To configure this warning use the DbContextOptionsBuilder.ConfigureWarnings API (event id 'RelationalEventId.QueryClientEvaluationWarning'). ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider. fail: Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler[1] An exception occurred in the database while iterating the results of a query. System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SNILoadHandle' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'sni.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at System.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize(IntPtr pmo) at System.Data.SqlClient.SNILoadHandle..ctor() at System.Data.SqlClient.SNILoadHandle..cctor() --- End of inner exception stack trace --- at System.Data.SqlClient.TdsParser..cctor() --- End of inner exception stack trace --- at System.Data.SqlClient.TdsParser..ctor(Boolean MARS,Boolean fAsynchronous) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo,Boolean redirectedUserInstance,SqlConnectionString connectionOptions,TimeoutTimer timeout) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout,Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,Object providerInfo,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData,Boolean applyTransientFaultHandling) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,DbConnectionPool pool,DbConnection owningConnection,DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool,DbConnection owningObject,DbConnectionOptions options,DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject,DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean allowCreate,Boolean onlyOneCheckConnection,DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,TaskCompletionSource`1 retry,DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,DbConnectionInternal oldConnection,DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory connectionFactory,DbConnectionOptions userOptions) at 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 operation,Func`2 verifySucceeded,TState state) at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) at lambda_method(Closure,QueryContext ) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_0`1.<CompileQueryCore>b__0(QueryContext qc) System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SNILoadHandle' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'sni.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at System.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize(IntPtr pmo) at System.Data.SqlClient.SNILoadHandle..ctor() at System.Data.SqlClient.SNILoadHandle..cctor() --- End of inner exception stack trace --- at System.Data.SqlClient.TdsParser..cctor() --- End of inner exception stack trace --- at System.Data.SqlClient.TdsParser..ctor(Boolean MARS,Boolean fAsynchronous) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo,TimeoutTimer timeout) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout,Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,Boolean applyTransientFaultHandling) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options,DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool,DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject,DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject,DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionOptions userOptions) at 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,TState state) at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) at lambda_method(Closure,QueryContext ) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_0`1.<CompileQueryCore>b__0(QueryContext qc) info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2] Executed action SearchDocumentsWebApp.Controllers.SearchApiController.SearchByTopic (SearchDocumentsWebApp) in 3176.7883ms fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0] An unhandled exception has occurred: The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception. System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SNILoadHandle' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'sni.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at System.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize(IntPtr pmo) at System.Data.SqlClient.SNILoadHandle..ctor() at System.Data.SqlClient.SNILoadHandle..cctor() --- End of inner exception stack trace --- at System.Data.SqlClient.TdsParser..cctor() --- End of inner exception stack trace --- at System.Data.SqlClient.TdsParser..ctor(Boolean MARS,QueryContext ) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_0`1.<CompileQueryCore>b__0(QueryContext qc) at SearchDocumentsWebApp.Controllers.SearchApiController.<SearchByTopic>d__8.MoveNext() in C:UsersgubertSourceReposAmdocsSearchDocumentsWebAppsrcSearchDocumentsWebAppControllersSearchAPIController.cs:line 76 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__25.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next,Scope& scope,Object& state,Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextResourceFilter>d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next,Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__20.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.<Invoke>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.ApplicationInsights.AspNetCore.RequestTrackingMiddleware.<Invoke>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext() 这是我的project.json: { "buildOptions": { "emitEntryPoint": true,"preserveCompilationContext": true },"dependencies": { "Microsoft.ApplicationInsights.AspNetCore": "1.0.2","Microsoft.AspNetCore.Authentication.Cookies": "1.1.0","Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0","Microsoft.AspNetCore.Authorization": "1.1.0","Microsoft.AspNetCore.Diagnostics": "1.1.0","Microsoft.AspNetCore.Mvc": "1.1.0","Microsoft.AspNetCore.Mvc.Core": "1.1.0","Microsoft.AspNetCore.Mvc.TagHelpers": "1.1.0","Microsoft.AspNetCore.Server.IISIntegration": "1.1.0","Microsoft.AspNetCore.Server.Kestrel": "1.1.0","Microsoft.AspNetCore.StaticFiles": "1.1.0","Microsoft.EntityFrameworkCore.Design": "1.1.0","Microsoft.EntityFrameworkCore.SqlServer": "1.1.0","Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final","Microsoft.Extensions.Configuration.Binder": "1.1.0","Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0","Microsoft.Extensions.Configuration.FileExtensions": "1.1.0","Microsoft.Extensions.Configuration.Json": "1.1.0","Microsoft.Extensions.Logging": "1.1.0","Microsoft.Extensions.Logging.Console": "1.1.0","Microsoft.Extensions.Logging.Debug": "1.1.0","Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.1.0","Microsoft.NETCore.App": "1.1.0","Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0","Newtonsoft.Json": "9.0.2-beta1","WindowsAzure.Storage": "7.2.1" },"frameworks": { "netcoreapp1.0": { "imports": [ "dotnet5.6","dnxcore50","portable-net45+win8" ] } },"publishOptions": { "include": [ "wwwroot","Views","web.config","appsettings.json","appsettings.*.json","LICENSE.txt" ] },"runtimeOptions": { "gcServer": true },"runtimes": { "win10-x64": {} },"scripts": { //"prepublish": [ "npm install","npm recompileapp" ],"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] },"tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final","Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-preview2-final","type": "platform","imports": [ "portable-net45+win8+dnxcore50","portable-net45+win8" ] } } } 我甚至试图将“Microsoft.EntityFrameworkCore.Tools”的“type”属性更改为“platform”,这样它就会复制它的dll,还试图将“System.Data.SqlClient.dll”复制到/ wwwroot / bin文件夹重新启动应用程序但仍然得到相同的错误. 在我的本地机器上它工作 解决方法
解决了!
azure web apps在Windows 2012 r2上运行,所以我需要设置win7运行时并将发布设置更改为win7-x64: "runtimes": { "win10-x64": {},"win7-x64": {} }, (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ASP基于B/S模式的失物招领系统
- asp.net-mvc-3 – 基于域的ASP.net MVC 3输出缓存
- asp.net-mvc-3 – 在同一视图中更新多个项目
- 将ASP.net Web API用作服务层是否合适?
- asp.net-mvc – 如何使用Windsor将依赖项注入到ActionFilte
- asp.net – 将unicode数字从英语转换为devanagari
- asp.net-mvc – 无法使用IIS Express在Windows 10上运行Web
- asp.net-web-api – 角色提供者/成员?如何在asp.net web a
- asp.net-mvc – 具有不同Http方法的RESTful控制器,但是相同
- asp.net-mvc – 如何将.NET Core 2 MVC Web应用程序编译为E
推荐文章
站长推荐
- asp.net-mvc – ServiceStack Funq IoC替代品
- CKEditor与CKFinder的配置
- asp.net-web-api – 如何存储Web API访问令牌?
- asp.net – 带有IE 11的ReportViewer 11:报告高
- asp.net – 如何在发布项目时交换连接字符串?
- asp.net-mvc – 字段子集的验证摘要
- asp.net – 为什么IIS Express使用而不是?
- Asp.net SignalR 让实时通讯变得如此简单
- asp.net-mvc – ASP.NET MVC从c#代码创建绝对url
- asp.net – AntFarm反模式 – 避免的策略,解毒帮
热点阅读