Partager via


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]

Comments

  • Anonymous
    October 26, 2007
    PingBack from http://ghillie-suits.info/?p=34525

  • Anonymous
    January 29, 2008
    Iea!! Toma tomate!! VIVA ESPAÑA!!

  • Anonymous
    February 26, 2008
    The comment has been removed

  • Anonymous
    March 24, 2008
    I too still have this issue after following these workarounds.  very frustrating!

  • Anonymous
    April 17, 2008
    try to put *NN.dll to C:Program FilesMicrosoft SQL Server90ToolsBinnVSShellCommon7IDE folder. It worked for me

  • Anonymous
    April 17, 2008
    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

  • Anonymous
    April 28, 2008
    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?)

  • Anonymous
    June 09, 2008
    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

  • Anonymous
    June 25, 2008
    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!

  • Anonymous
    July 22, 2008
    The comment has been removed

  • Anonymous
    July 23, 2008
    The comment has been removed

  • Anonymous
    July 24, 2008
    Hi, 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: http://windowsfordevices.com/articles/AT7568439504.html (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.

  • Anonymous
    July 25, 2008
    Apologies - (think) I pasted the wrong link in my last comment. Forum link to issue is: http://forums.microsoft.com/technet/showpost.aspx?postid=220816&siteid=17&sb=0&d=1&at=7&ft=11&tf=0&pageid=1 Cheers, Gary

  • Anonymous
    August 17, 2008
    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

  • Anonymous
    October 19, 2008
    The comment has been removed

  • Anonymous
    November 02, 2008
    Hi, 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+

  • Anonymous
    November 05, 2008
    Any chance of getting pure .Net implementation that does not need native dlls?

  • Anonymous
    November 06, 2008
    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. Thanks, Laxmi

  • Anonymous
    January 07, 2009
    SQL Compact And The "Unable to load DLL 'sqlceme35.dll'" Runtime Exception