SQL Server LocalDB 实例无法启动(自动) [英] SQL Server LocalDB instance fails to start (automatically)

查看:42
本文介绍了SQL Server LocalDB 实例无法启动(自动)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WPF 应用程序,它连接到 SQL Server 2014 Express LocalDB(即本地 .mdf 数据库文件).

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

应用程序使用 Entity Framework Core 库版本 7.0.0-rc1-final.

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

我在应用程序设置期间安装 SQL Server LocalDB.SqlLocalDB Instance 的创建和启动也是如此,通过这个命令来执行:

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"

该应用在大约 50 台 PC 上成功运行,但在以下两台 PC 上失败:

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

一开始,应用程序成功与数据库通信,但过了一段时间,如果没有活动,实例会自动停止(大约10分钟后),然后再次重新连接失败,导致以下这些错误:

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:

您的 SQL Server 安装已损坏或已被篡改(包 ID 未知).

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

使用上述相同的命令行手动启动 LocalDB 实例:

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

SqlLocalDB.exe start "SqlLocalDBInstance"

应用程序成功与数据库通信,直到下一次 LocalDB 实例停止,依此类推.

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

Windows 日志显示以下错误:

Windows logs shows this following error:

Windows API 调用 WaitForMultipleObjects 返回错误代码:575.
Windows 系统错误消息是:{Application Error} 应用程序无法正确启动 (0x%lx).单击确定"关闭应用程序.

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 日志文件提供了此通知消息:

SQL LocalDB log files provided this notification message:

RANU 实例正在终止以响应其内部超时.这只是一条信息性消息.无需用户操作.

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

我已经重新安装并重新安装了(Microsoft SQL Server 2014 Express 以及删除了 .mdf.ldf 文件),并且不断得到同样的错误.

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.

我注意到两台有问题的机器都关闭了 UAC;所以我试图在关闭 UAC 的测试机器上重现该问题 - 没有重现该问题.

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.

两台有问题的机器在 64 位 Windows 10 专业版下运行.

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?

我已将整个应用程序文件夹(及其所有二进制文件)重新定位到C:Program Files (x86)"之外

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

目录到C:"路径内的其他目录,问题就解决了.

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. 取消选中文件夹属性的只读"选项.

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

为应用程序文件夹启用所有安全"权限.

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?

推荐答案

终于找到了问题的根源.

At last I Found the root of the problem.

问题在于应用程序可执行文件的兼容模式,该模式设置为在兼容模式下运行此程序:Windows 8"(在文件属性中的兼容性"选项卡下).

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.

这篇关于SQL Server LocalDB 实例无法启动(自动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆