2016-10-05 88 views
0

我有一个.NET Core命令行应用程序,我已作为webjob部署到Azure。
当我尝试在应用程序,我收到以下错误消息来访问数据库:
无法在azure Webjob中加载sni.dll

[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) 


不知道是否有人有同样的问题,并找到解决方法或修复它。过去两天我一直试图解决这个问题,但没有成功。
谢谢。

+0

你能清理一下你的格式吗? – evilSnobu

+0

请参阅[本页](https://github.com/projectkudu/kudu/wiki/Isolating-WebJobs-and-Deployment-script-issues)以获取隔离的初始步骤。 –

回答

1

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

1.You需要确保你在Project.json如下:

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

煤矿没有足够的“类型”:“平台”的一部分。

  • 最主要的是,你需要有一个文件在您的项目的根命名run.cmd并将其包含在您发布的输出,以及:

    @echo关闭 dotnet NameOfYourProject.dll进程

  • 这些更改后,一切正常工作。 希望这会帮助其他人并节省他们的时间。

    0

    和我一样,我改变了。

    "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" 
         } 
         } 
        } 
        },