“Unable to load DLL” problem with SQL Server CE

I got an error when using SQL Server Compact 3.5 (SqlCe) with asp.net MVC3 web application.

The error is like: “Unable to load DLL ‘sqlcese35.dll’: The specified module could not be found. (Exception from HRESULT: …

When looking this issue, I found that SQL CE is not installed in GAC so the reference is added from its installation folder. e.g. C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Private. And the file name is “System.Data.SqlServerCe.dll".

This assembly requires several native DLLs to work. They are (possibly):

sqlcea35.dll

sqlcecompact35.dll

sqlceer35en.dll

sqlceme35.dll

sqlceoledb35.dll

sqlceqp35.dll

sqlcese35.dll

I’m not sure which of these are really needed. To avoid further problems, I copied all of them into my project’s “bin” folder. bingo, now it works!

This problem brings an additional deployment step for my web application. I know “xcopy” is easy to deal with. But in the future I would like to take a look for other alternatives against SQL Server CE, e.g. sqlite. Although I’m not sure if it’s a one-file solution.

原文地址:https://www.cnblogs.com/brucejia/p/2361168.html