代码之家  ›  专栏  ›  技术社区  ›  Łukasz Bryniarski

ASP。Windows IoT raspberry pi上的NET MVC无法连接到SQL数据库

  •  1
  • Łukasz Bryniarski  · 技术社区  · 6 年前

    我正在尝试使用Windows IoT系统在Raspberry Pi 3上启动MusicStore应用程序。NET核心2.0.4。

    我设法用ubuntu在Raspberry上运行它,但在Windows中,我从 screenshot (很抱歉没有复制它,但我在putty中没有遇到错误,所以我需要使用Windows IoT命令行,我无法在任何地方复制此文本)。

    这两个系统都连接到我电脑上的数据库,linux能够运行应用程序,而Windows出现故障,所以这不是连接字符串的错误。 我之前对失踪的sni有问题。dll,但正如 this thread 我通过复制unix修复了它。

    知道怎么了吗?

    编辑: 今天我在我的旧电脑(win10-x64)上测试了它,我得到了与Windows IoT相同的错误,所以我可以在这里复制它。

    Unhandled Exception: System.AggregateException: One or more errors occurred. (A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 44 - Could not compose Service Principal Name (SPN) for Windows Integrated Authentication. Possible causes are server(s) incorrectly specified to connection API calls, Domain Name System (DNS) lookup failure or memory shortage)) ---> System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 44 - Could not compose Service Principal Name (SPN) for Windows Integrated Authentication. Possible causes are server(s) incorrectly specified to connection API calls, Domain Name System (DNS) lookup failure or memory shortage) ---> System.Net.Sockets.SocketException: Nieznany host
        at System.Net.Dns.InternalGetHostByAddress(IPAddress address)
        at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
        at System.Data.SqlClient.SNI.SNIProxy.GetSqlServerSPN(String hostNameOrAddress, String portOrInstanceName)
        at System.Data.SqlClient.SNI.SNIProxy.GetSqlServerSPN(DataSource dataSource)
        at System.Data.SqlClient.SNI.SNIProxy.CreateConnectionHandle(Object callbackObject, String fullServerName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[]& spnBuffer, Boolean flushCache, Boolean async, Boolean parallel, Boolean isIntegratedSecurity)
    --- End of inner exception stack trace ---
        at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, 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, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
        at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
        at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
        at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
        at System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
    --- End of stack trace from previous location where exception was thrown ---
        at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
        at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerDatabaseCreator.<>c__DisplayClass20_0.<<ExistsAsync>b__0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
        at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerDatabaseCreator.<>c__DisplayClass20_0.<<ExistsAsync>b__0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
        at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
        at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreatedAsync(CancellationToken cancellationToken)
        at MusicStore.Models.SampleData.InitializeMusicStoreDatabaseAsync(IServiceProvider serviceProvider, Boolean createUsers) in C:\Users\lukas\Documents\projekty\magister\MusicStore\Models\SampleData.cs:line 27
    --- End of inner exception stack trace ---
        at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
        at System.Threading.Tasks.Task.Wait()
        at MusicStore.Startup.Configure(IApplicationBuilder app) in C:\Users\lukas\Documents\projekty\magister\MusicStore\Startup.cs:line 220
        at MusicStore.Startup.ConfigureProduction(IApplicationBuilder app) in C:\Users\lukas\Documents\projekty\magister\MusicStore\Startup.cs:line 171
    --- End of stack trace from previous location where exception was thrown ---
        at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
        at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
        at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
        at MusicStore.Program.Main(String[] args) in C:\Users\lukas\Documents\projekty\magister\MusicStore\Program.cs:line 67
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Michael Xu    6 年前

    据我所知,arm上的Windows物联网核心无法连接到MS SQL Server。你可以追踪这个问题( #9064 )在GitHub上。 您可以使用额外的web服务或wcf,并通过REST-API进行通信来解决这个问题。