且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法连接到Localdb,但可以使用namedpipe

更新时间:2023-02-25 18:39:52

进一步调查后,我在应用程序甚至查看器"中发现了这些错误

After further investigation I found these errors in the Application even viewer

Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.

Windows API call SHGetKnownFolderPath returned error code: 5. Windows system error message is: Access is denied.
Reported at line: 422. 

这促使我找到解决该问题的这篇文章.

Which led me to find this article that solved the issue.

主要是我必须进行以下更改:

Mainly I had to do these changes:

1. Change the loadUserProfile="true"   to true for the App Pool running the app. 
2. Create a share for my localdb instance and use that in my connection string. 
3. Change the local instance stop time to indefinite
Run the following batch to change the timeout to 65535. This value is in   seconds, but 65535 is the magic number meaning infinite:
exec sp_configure 'user instance timeout',65535
reconfigure
exec sp_configure 'user instance timeout'
go

查看全文