SQL Server LocalDB instance fails to start (automatically)

若如初见. 提交于 2021-02-16 21:02:35

问题


I have a WPF application which is connecting to the SQL Server 2014 Express LocalDB (i.e. a local .mdf database file).

The application uses the Entity Framework Core library version 7.0.0-rc1-final.

This is the connection string that I am using:

data source=(LocalDb)\InstanceLocalDB; Initial Catalog = MyAppDB; Integrated Security=True; MultipleActiveResultSets=True; Connection Timeout = 10

I do the installation of the SQL Server LocalDB during the application's setup. The same goes for the creation and starting of the SqlLocalDB Instance, which is performed with this command:

SqlLocalDB.exe create "SqlLocalDBInstance"
SqlLocalDB.exe start "SqlLocalDBInstance"

The app runs successfully on approximately 50 PCs, but fails on two as follows:

At first, the application successfully communicates with the database, but after awhile, if there is no activity, the instance is stopping automatically (after about 10 minutes), and from then it fails to reconnect again, which result in these following error:

Your SQL Server installation is either corrupt or has been tampered with (unknown package id).

On starting the LocalDB instance manually using the same command line mentioned above:

SqlLocalDB.exe start "SqlLocalDBInstance"

the application successfully communicates with the DB, until the next time the LocalDB instance is stopping, and so on.

Windows logs shows this following error:

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.

SQL LocalDB log files provided this notification message:

The RANU instance is terminating in response to its internal time out. This is an informational message only. No user action is required.

I have installed and re-installed all over again (both Microsoft SQL Server 2014 Express as well as deleted the .mdf and .ldf files), and keep getting the same error.

I noticed that in both of problematic machines the UAC was turned off; so I tried to reproduce the issue on test machines with the UAC turned off - there wasn't any reproduction of the problem.

The 2 problematic machines runs under Windows 10 pro 64bit.

Finally, after further investigation, i found a workaround by renaming the application folder or by changing its location.

How I recognized the solution?

I have relocated the whole application folder (with all of its binaries) outside of the "C:\Program Files (x86)"

directory into other directory within the "C:\" path, and the problem has gone.

In the same manner, I moved the application folder back to its original location; only now I changed the

name of the application folder, and it worked again.

Maybe the issue is somehow related to the directory permissions.

Nevertheless, i did these steps below, but without any success:

  1. Unchecked the 'Read-only' option for the folder's Attribute.

  2. Enabled all 'Security' permissions for the application folder.

Note: I'm working in an organization domain with all kinds of custom policies...

My next move is to use some utility tool to extract all the permissions of the application folder, and then to try to trace the root of the problem. Can you suggest me some tools for this?


回答1:


At last I Found the root of the problem.

The issue was with the Compatibility mode of the application's executable file, that was set to "Run this program in compatibility mode for: Windows 8" (under the 'Compatibility' tab within the file's Properties).

Once I removed (unchecked) this option, the error has gone, and the issue was finally closed for me.




回答2:


I had a similar problem regarding permissions of system folders. I used AccessEnum from SysInternals for this task.

See here: https://docs.microsoft.com/en-us/sysinternals/downloads/accessenum



来源:https://stackoverflow.com/questions/51011597/sql-server-localdb-instance-fails-to-start-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!