SQL Server CE extremely slow on some computers

那年仲夏 提交于 2019-12-06 09:26:35
XKCD137

The intermediate cause and workaround for this problem is with User access to .NET cryptography files used by a password-protected database. The problem was solved by changing the permissions on the folder.

You can open command prompt with Run-As Admin and issue this command (Win XP)

 cacls.exe "C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys" /E /G Everyone:R

I also added this comment to my code near the SQLCE connection string code:

 /**************************************************************************************
 * To get rid of the slowdown on non-admin users you need to grant them read access to this folder:
 * C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys  (XP, 2003)
 * C:\Users\All Users\Microsoft\Crypto\RSA\MachineKeys  (Windows 7 or 2008)
 **************************************************************************************/

This issue is mentioned here: SqlCe opens slow under a limited user account in Windows XP

And here: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/eb6a01a7-0bfd-41e3-b4c8-34581c5ccaa3/sql-compact-4-locks-up-30seconds-when-accessing-encrypted-database-on-windows-xp-when-running-in?forum=sqlce

Note: on the problem machine, the ...\MachineKeys folder was visible in WinExplorer, but the files couldn't actually be read. "Everyone" had "special" permissions that didn't allow "Read". I think .NET may have been installed by Domain admin, not local admin.

This is only a workaround. I still don't understand why the folder had weird permissions on a few machines but not the rest. I am deploying with ClickOnce, so I can't change the folder permissions automatically.

I have only seen this problem with XP, and other posts imply that this is just an XP problem, so hopefully I won't have to worry about it for long...

I had a similar problem with SQL Server CE. I found that installing the latest version from http://www.microsoft.com/en-us/download/details.aspx?id=17876 resolved the problem

I suspect that those machines already have an earlier version of SQL Server CE installed in the global assembly cache, and that the earlier version is being used instead of the locally deployed version.

Also, check the information from Lingzhi Sun in this post. Aparrently if the database is used on a different operating system from the one on which it was created, this can cause performance problems. This blog post may also be helpful.

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