Welcome to MSDN Blogs Sign in | Join | Help

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>

OR

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

 

Thanks,

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]

Published Friday, October 26, 2007 9:01 PM by SQLCEBLOG
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Ghillie Suits &raquo; Can&#8217;t find P/Invoke DLL sqlcemeNN.dll

# re: Can’t find P/Invoke DLL sqlcemeNN.dll

Tuesday, January 29, 2008 12:56 PM by Don Quijote

Iea!! Toma tomate!!

VIVA ESPAÑA!!

# re: Can’t find P/Invoke DLL sqlcemeNN.dll

Tuesday, February 26, 2008 11:30 PM by Kurt

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

Can't find PInvoke DLL 'sqlceme35.dll'.

# re: Can’t find P/Invoke DLL sqlcemeNN.dll

Tuesday, March 25, 2008 5:26 AM by westwok

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

# re: Can’t find P/Invoke DLL sqlcemeNN.dll

Friday, April 18, 2008 5:11 AM by Jirapong

try to put *NN.dll to C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\ folder. It worked for me

# re: Can’t find P/Invoke DLL sqlcemeNN.dll

Friday, April 18, 2008 5:53 AM by laxminro

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.

Thanks,

Laxmi

# re: Can’t find P/Invoke DLL sqlcemeNN.dll

Monday, April 28, 2008 8:07 AM by martinleitner

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?)

# re: Can’t find P/Invoke DLL sqlcemeNN.dll

Monday, June 09, 2008 1:38 PM by laxminro

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.

Thanks,

Laxmi

# re: Can’t find P/Invoke DLL sqlcemeNN.dll

Thursday, June 26, 2008 2:23 AM by Michael Flynn

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!

# re: Can’t find P/Invoke DLL sqlcemeNN.dll

Monday, August 18, 2008 5:44 AM by laxminro

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: http://blogs.msdn.com/sqlservercompact/archive/2008/08/13/released-sql-server-compact-v3-5-sp1-sql-server-2008-rtm-visual-studio-2008-sp1-net-framework-v3-5-sp1.aspx.

Thanks,

Laxmi

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker