I recently started working at a company for whom I need to modify software to support connecting to our SQL Server database and connecting to a LocalDB instance. For testing purposes, I decided to use Windows Sandbox. I've also tried with a Hyper-V VM and additional "backup" PCs with similar results.
The program itself is a C# .NET Framework v4.6.1 application, installed using ClickOnce. The ClickOnce installer has a prerequisite for SQL Server 19 LocalDB which gets installed prior to the program running from the vendor's website. Upon launching the program, I select to connect to a local database, which is a code generated string, but the LocalDB fails to start. The connection string looks something like this due to being generated for Entity Framework 6 (formatted for readability):
metadata=res://*/DeadweightModel.csdl|res://*/DeadweightModel.ssdl|res://*/DeadweightModel.msl;
provider=System.Data.SqlClient;
provider connection string='
Data Source=(LocalDB)\MSSQLLocalDB;
AttachDbFilename="C:\ProgramData\Company Directory\database.mdf";
Integrated Security=True;
Pooling=False;
MultipleActiveResultSets=True;
Connect Timeout=30;
Application Name=EntityFramework'
The connection ultimately just times out. Since I've been dealing with this branch for a few weeks on and off, I've learned to ignore the connection string for now and just focus on the LocalDB installation instead. In a fresh sandbox instance, I used the ClickOnce installer to install the LocalDB '19 version and attempted to start the default instance from PowerShell. Here are the results:
PS C:\Program Files\Microsoft SQL Server\150\Tools\Binn> .\SqlLocalDB.exe info
MSSQLLocalDB
PS C:\Program Files\Microsoft SQL Server\150\Tools\Binn> .\SqlLocalDB.exe create
Creation of LocalDB instance "MSSQLLocalDB" failed because of the following error:
Error occurred during LocalDB instance startup: SQL Server process failed to start.
PS C:\Program Files\Microsoft SQL Server\150\Tools\Binn> .\SqlLocalDB.exe create
LocalDB instance "MSSQLLocalDB" created with version 15.0.2000.5.
Something to notice here is that the first attempt to create the default instance fails, but subsequent attempts succeed.
PS C:\Program Files\Microsoft SQL Server\150\Tools\Binn> .\SqlLocalDB.exe start
Start of LocalDB instance "MSSQLLocalDB" failed because of the following error:
Error occurred during LocalDB instance startup: SQL Server process failed to start.
It doesn't matter how many times I attempt to start the instance, it just fails. Every failure here has a corresponding Windows Application logged event as follows:
Windows API call WaitForMultipleObjects returned error code: 575. Windows system error message is: {Application Error}
The application was unable to start correctly (0x%lx). Click OK to close the application.
Reported at line: 3714.
And the LocalDB log shows:
2021-07-01 09:38:47.19 spid14s Starting up database 'mssqlsystemresource'.
2021-07-01 09:38:47.19 spid20s Error: 17826, Severity: 18, State: 4.
2021-07-01 09:38:47.19 spid20s Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
2021-07-01 09:38:47.19 spid20s Error: 17120, Severity: 16, State: 1.
2021-07-01 09:38:47.19 spid20s SQL Server could not spawn FRunCommunicationsManager thread. Check the SQL Server error log and the operating system error log for information about possible related problems.
All of that being said, I've attempted to manually install LocalDB '16, '17, and '19 manually (through the SQL Server installer), all with similar results. I've tried doing these steps on a new Virtual Machine running Windows 10 Pro and a freshly restored Windows 10 Home PC with the same results. On our dev computers and our production computers, LocalDB works as expected. The issue is that this needs to work, out of the box, on a brand new, fresh install of Windows 10 and it doesn't. I'd also like to get it working in Sandbox for development purposes.
I have tried doing a full install of SQL Server Express in the Sandbox, which fails. Per some suggestions on SO, I've installed VC++ '15-19, which helped the manual installs actually install, but they still didn't start. I managed to get the LocalDB default instance to start a few times previously, but every time I managed to it was immediately stopped and I still couldn't connect to it.
Sorry for the long winded post, but I'm at my breaking point with troubleshooting this and all of the searching that I've done has ended with no changes. Please, any suggestions are welcome.