簡體   English   中英

Windows IoT樹莓派上的ASP.NET MVC無法連接到SQL數據庫

[英]ASP.NET MVC on Windows IoT raspberry pi unable to connect to SQL database

我正在嘗試使用帶有.NET Core 2.0.4的Windows IoT系統在Raspberry Pi 3上啟動MusicStore應用程序。

我設法使用ubuntu在Raspberry上運行它,但是在Windows中,我從屏幕截圖中得到了一個錯誤(很抱歉沒有復制它,但是膩子沒有錯誤,所以我需要使用Windows IoT命令行,但我無法將此文本復制到任何地方)。

兩個系統都連接到我PC上的數據庫,而Windows出現故障時,Linux能夠運行應用程序,因此這不是連接字符串的錯誤。 以前我缺少sni.dll時遇到問題,但是如該線程中所述,我通過復制UNIX修復了它。

任何想法有什么問題嗎?

編輯:今天我在舊PC(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

據我所知,Windows IoT核心版無法連接到MS SQL Server。您可以在GitHub上跟蹤問題( #9064 )。 您可以使用其他Web服務或wcf並通過REST-API進行通信來變通。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM