I know this is very annoying, uninformative, directionless…blah blah… error. And, kindly pardon me for blogging about this error very lately. Better late than never and here it goes.
What are the actual errors?
What are the actual errors?
1) Can't find P/Invoke DLL sqlceme30.dll 2) Can't find P/Invoke DLL sqlceme35.dll 3) Can't find P/Invoke DLL sqlceme40.dll
1) Can't find P/Invoke DLL sqlceme30.dll
2) Can't find P/Invoke DLL sqlceme35.dll
3) Can't find P/Invoke DLL sqlceme40.dll
What exactly this error means?
When a managed assembly (In our case, System.Data.SqlServerCe.dll) is trying to P/Invoke a method on to a native DLL (In our case, sqlcemeNN.dll; where NN stands for version of product 30, 35 …etc), system has failed to find the DLL to load and invoke the method.
When do we get this error?
We get this error when system cannot find the DLL in the system path, or current process executable path.
How can one land in this error? What are the probable workarounds or fixes?
There are multiple cases and some of the well known ones are given below:
1) Prior to .NET CF 2.0 SP2, there is no concept of GAC on storage card. And, if you have installed SQL CE Cab on storage card with .NET CF 2.0 RTM/SP1 on device, our native DLLs end up on storage card and the GAC on the main memory. Hence, managed assembly will fail when P/Invoking above method
a. Please use .NET CF SP2 and above
b. Please install the cabs on main memory
c. Please move to SQL CE 3.0 SP2/3.1 and above
2) You are developing the application for smart devices (Windows CE OS based) and using Visual Studio Auto Deployment (F5) feature. And, VS has failed to map the System.Data.SqlServerCe.dll to the right set of cabs to install and just deployed the System.Data.SqlServerCe.dll alone (Note: No error is thrown). In this case, the native DLLs are not deployed.
a. Fix the auto-deployment issues (Don’t ask me how L)
b. Remove and add the reference to System.Data.SqlServerCe. This is because, VS IDE stores assembly identity in the project file. Since we have changed the assembly version in SQL CE v3.5 SP1, removing and adding updates the solution to host the right assembly version
c.Manually copy and install the SQL CE Cabs (all the 3 cabs). They are located under:
%ProgramFiles%\Microsoft SQL Server Compact Edition\<version>\Devices\<platform>\<processor>
3) System has failed to load the sqlcemeNN.dll. To find more details on why system might have failed to load a module is discussed in my previous blog post.
4) If your machine is a 64-bit box, you might have been got trapped into default target platform 'Any CPU' trap, please set the target platform as 'x86'. Need more details, please visit ErikEJ's blog post.
5)In all other cases, please move to SQL CE 3.0 SP2/3.1 and above. If possible make sure HKLM\Software\Microsoft\Microsoft SQL Server Compact Edition\<Version>\NativeDir registry points to the directory where our native DLLs are installed. Please consider the WoW registry if running in WoW mode.
Laxmi Narsimha Rao ORUGANTI
[Update: Edited Actual Errors section to see if it helps in catching Live/Google's eye]
[Update: Added 64-bit box story and also a reference to ErikEJ's blog post]