Can’t find P/Invoke DLL sqlcemeNN.dll

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?

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:

%VisualStudioInstallRoot%\SmartDevices\SDK\SQL Server\Mobile\v3.0\<platform>\<processor>


%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]

Comments (19)

  1. Don Quijote says:

    Iea!! Toma tomate!!


  2. Kurt says:

    This was useless, does anybody know how to fix this damn issue?

    Can’t find PInvoke DLL ‘sqlceme35.dll’.

  3. westwok says:

    I too still have this issue after following these workarounds.  very frustrating!

  4. Jirapong says:

    try to put *NN.dll to C:Program FilesMicrosoft SQL Server90ToolsBinnVSShellCommon7IDE folder. It worked for me

  5. Kurt and Westwok,

      Can you please provide us more details so that we can try to narrowdown the issue which is happening in your case.

      With out any details, it is very hard for us to help you guys out.

      If you have a stand alone mini repro, please use contact/email page of this blog to start a direct conversation and we can exchange repros.



  6. martinleitner says:

    How to get SQL CE 3.5 into an image built by Platformbuilder 6.0? It seems that a catalog item is missing! There is only a set of .cab files which is not useful at all!!! (Or will you imagine, a customer will re-install the sql server every time the device is powered on?)

  7. Hi Martin Leitner,

    SQL CE v3.5 SP1 release would be available as a catalog item in Platform Builder versions 5.0, 6.0, 7.0.  SQL CE v3.5 SP1 is slated to be released along with VS 2008 SP1 and SQL Server 2008.



  8. Check for any references to missing files in the Solution Explorer.  I had added an icon  to the project, but then deleted the .ico file from the disk without removing the reference to the file in the project. As soon as I removed the reference to the missing file from the project instantly the deploy starting working again!

  9. Marco Balk says:

    [quote]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’.[/qoute]


    Saved me from a lot of braindamage 🙂


  10. Marcel says:

    Lost a week now for googling, installing, reinstalling, trying other combinations.

    sqlceme35.dll is definitely on the virtual device but could not be found at runtime.

    Cluttered my hd with sqlceme35.dll’s and it didn’t help.

    Installed vs2005 SP1 vs2008 on my Vista 64 Box, and anything i could find about sqlce. Target Device is Windows Mobile Professional 6

    tryed all on this page without effect. (VS2008 wont let me add an x86 configuration)

    Any ideas (except to buy a ipod)

  11. Gary says:


    Not sure if this is related to the above (or not) but we’re having problems similar to the above getting SQL Compact 3.5 running on a number of CE 5 Core devices.

    Details on the forum at:

    (Poster is Louis)

    Any thoughts or assistance would be greatly appreciated as we’re pulling our hair out and can’t even seem to raise a Microsoft Support call on the issue.

  12. Gary says:

    Apologies – (think) I pasted the wrong link in my last comment.

    Forum link to issue is:

    Cheers, Gary

  13. Hey folks,

      As promised, we released Platform Builder 5.0 and 6.0 catalog integration for SQL Server Compact v3.5 SP1.  Please check out the blog:



  14. sumeet says:

    Please check for your OS Design

    in catalog search for database and find database support and check all the components it will work

    it worked 4 me

  15. selmaguzel says:


    I get the same error after trying to follow most of the steps you say,but still, the same error:(

    1-)I use cf2.0 under wince5.0.

    2-)I installed the 3 cab files.

    Then I got the same error.

    3-) I couldn’t add or edit cpu as x86 from Configuration Manager,but set from project properties’ Build part.

    Again i got the same error.

    I got error "CF100:Could not open file for writing" when I run the command below :

    corflags myappname.exe /32BIT+

    4-)I checked the registry at last.There are directories as SQL Mobile 2005,SQL Mobile 2005[EN] and SQL Mobile 2005 Replication.But there are not any folders under them.

    Otherwise, there is MSSQLServerCE which I added in OS Design.

    Now, what must I do then?

    I am really bored, but i want to solve!

    Please help!

    corflags myapplicationname.exe /32BIT+

  16. Slawek says:

    Any chance of getting pure .Net implementation that does not need native dlls?

  17. Hey Selmaguzel,

     The erorr you are receiving is entirely different from what this article explains.  The error "CF100:Could not open file for writing" is related to permissions and attributes of the file it is trying to open.  

     Please use newsgroup: microsoft.sqlserver.ce or MSDN forum for questions for thorough follow-up.



  18. SQL Compact And The "Unable to load DLL ‘sqlceme35.dll’" Runtime Exception

Skip to main content