SqlClient: Cannot connect to (localdb) from .NET Core except via Named Pipe on Windows 11 ARM
Description
I’m trying to connect to SQL Server Express LocalDB from .NET Core 6 on Windows 11 ARM. If I use a connection string that refers to it using the instance name “Data Source=(localdb)\MSSQLLocalDB”, it fails with the exception below. If I connect to it using a named pipe, it works.
Microsoft.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: SNI_PN11, error: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry. Verify that the Local Database Runtime feature of SQL Server Express is properly installed.) —> System.ComponentModel.Win32Exception: %1 is not a valid Win32 application.
I’ve created some simple MSTest unit tests to repro the problem. There are two test methods in the DatabaseConnectionFixture class that attempt to connect to LocalDB: one uses an ordinary connection string and the other uses a named pipe. On Windows 11 ARM, the ConnectToDatabase_ConnectionString()
method fails. If I run this same code on Windows 11 x64, both tests pass.
Configuration
This is running on Windows 11 ARM in a Parallels VM on an M1 MacBook Pro. The OS Build # is 22509.1011. The dotnet core build is 6.0.100.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 4
- Comments: 25 (6 by maintainers)
Ran into this issue when attempting to debug an ASP.NET 4.8 app on the Windows Dev Kit 2023 yesterday. Given that The VS 2022 ARM64 Preview installs SQL Server 2019 LocalDB as part of the ASP.NET/web development workload, I expected it would be ready.
Curiously, Azure Data Studio connects and runs queries fine (including using the same connection string), and I was able to get a .NET 6 console app to connect and run a query, but only when the build configuration is set to x64 (and not ARM64). The ASP.NET 4.8 still has the same issue when running as x64.
I’ve created a report in the Visual Studio feedback site, hopefully they’re able to determine who owns the library and get it fixed.
Just wanted to report that this issue also concerns a native Windows 11 ARM installation on a Surface Pro X. Yet having troubles to install SQL Server 2019 at all (SQL Server Express, SQL Server Express Advanced and SSMS won’t install without errors), the SQL Server 2019 LocalDB installation somehow manages to get through successfully. However, trying to access the local database via connection string
(localdb)\MSSQLLocalDB
as part of developing a Blazor WASM application gave me exactly the same error as in the original post (provider: SNI_PN11, error: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry).Developing using VS Code, I installed the SQL server extension for VS Code (https://docs.microsoft.com/en-us/sql/tools/visual-studio-code/sql-server-develop-use-vscode). Interestingly enough, trying to access the LocalDB via connection string using this extension succeeds on ARM, even starting the database instance if previously stopped. I verified this behaviour calling
sqllocaldb info mssqllocaldb
before and after accessing the database using the SQL server extension, which gave me anInstance: Stopped
with no instance pipe name formerly and anInstance: Running
alongside an instance pipe name afterwards.The Microsoft Surface Pro X has been configurated with a Microsoft SQ2 Processor and 16 GB RAM, running Windows 11 Build 22000.434 on arm64.
Been broken forever…
Same here, just bought an Surface Pro 9 SQ3 now that Visual Studio has support for ARM64, but it is not possible to connect to localdb (even though it installs together with supported workload) from NET7/EF7. Azure Data Studio ARM64 can connect successfully so no issue with localdb per se.
@benday, I have not looked into the repro you have provided or much in details just some quick notes, have you tried with ssms to see if that gets a connection? LocalDb can use two different connection strings.
(localdb)\<Instance name>
or(localdb)\.\<shared instance name>
or(localdb)\.
. Last one connects to default local db which isMSSQLLocalDB
np:\.\pipe\LOCALDB#\tsql\query
The first one should be working without any issues, but there is an open issue for second one #1395 and PR #1433 is made to address issue.
One other problem with Instance pipe name is if its state is stopped you wont be able to get a connection from Instance pipe name. make sure you have ran
SqlLocalDB start <instance name>