【问题标题】:Unable to load sni.dll in azure Webjob无法在 azure Webjob 中加载 sni.dll
【发布时间】:2016-10-05 06:32:49
【问题描述】:

我有一个 .NET Core 命令行应用程序,我已将其作为 Web 作业部署到 Azure。
当我尝试访问应用程序中的数据库时,我收到以下错误消息:

[10/05/2016 06:23:27 > 5c77b6: ERR ] Unhandled Exception: System.AggregateException: One or more errors occurred. (Unable to load DLL 'sni.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)) ---> System.DllNotFoundException: Unable to load DLL 'sni.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Data.SqlClient.SNINativeMethodWrapper.UnmanagedIsTokenRestricted(IntPtr token, Boolean& isRestricted)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Data.Win32NativeMethods.IsTokenRestrictedWrapper(IntPtr token)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrent()
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Data.ProviderBase.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory connectionFactory)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection owningObject, DbConnectionPoolGroup connectionPoolGroup)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Data.SqlClient.SqlConnection.Open()
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open()
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.MoveNext()
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext()
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__15`2.MoveNext()
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at CommerceVision.InteractivePurchasingModule.Workflow.DuplicateCheckWorkflowProcessor.<GetUnProcessedEmails>d__4.MoveNext()
[10/05/2016 06:23:27 > 5c77b6: ERR ] --- End of stack trace from previous location where exception was thrown ---
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at CommerceVision.InteractivePurchasingModule.Workflow.DuplicateCheckWorkflowStep.<Process>d__7.MoveNext()
[10/05/2016 06:23:27 > 5c77b6: ERR ] --- End of stack trace from previous location where exception was thrown ---
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at CommerceVision.InteractivePurchasingModule.Workflow.WorkflowEngine.<Execute>d__3.MoveNext()
[10/05/2016 06:23:27 > 5c77b6: ERR ] --- End of stack trace from previous location where exception was thrown ---
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at CommerceVision.IpWorkflowProcessor.Program.<>c.<<ConfigureApplication>b__19_2>d.MoveNext()
[10/05/2016 06:23:27 > 5c77b6: ERR ]    --- End of inner exception stack trace ---
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
[10/05/2016 06:23:27 > 5c77b6: ERR ]    at CommerceVision.IpWorkflowProcessor.Program.Main(String[] args)


不确定是否有其他人遇到过同样的问题并找到解决方法或修复它。在过去的两天里,我一直在尝试解决这个问题,但没有成功。
谢谢。

【问题讨论】:

  • 你能清理一下你的格式吗?
  • 请参阅this page 了解最初的隔离步骤。

标签: .net azure azure-webjobs dotnet-cli


【解决方案1】:

好的,我发现了问题。 有2个问题。

1.您需要确保Project.json中有以下内容:

"Microsoft.NETCore.App": {
        "version": "1.0.0",
        "type": "platform"
    },

我的没有 "type": "platform" 部分。

  1. 主要是你需要在项目的根目录下有一个名为 run.cmd 的文件,并将它包含在你的发布输出中:

    @echo 关闭 dotnet NameOfYourProject.dll 进程

这些更改后一切正常。 希望这将有助于其他人并节省他们的时间。

【讨论】:

    【解决方案2】:

    和我一样,我变了。

    "frameworks": {
        "netcoreapp1.0": {
          "imports": [
            "dotnet5.6",
            "portable-net45+win8"
          ]
        }
      }
    

    到。

    "frameworks": {
        "netcoreapp1.1": {
          "imports": [
            "dotnet5.6",
            "dnxcore50",
            "portable-net45+win8"
          ],
          "dependencies": {
            "Microsoft.NETCore.App": {
              "version": "1.1.0",
              "type": "platform"
            }
          }
        }
      },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 2020-06-16
      • 1970-01-01
      相关资源
      最近更新 更多