Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Visual Studio to deploy dbnetlib.dll on Windows CE

I'm developing a device application, using a connection with a 'regular' Sql Server 2005 (not a Compact DB). Whenever I try to open SqlConnection on Windows CE (a Datalogic Memor CE), I’m getting a MissingMethodException: Can't find PInvoke DLL 'dbnetlib.dll'..

This seems to be a deployment issue. In my project I include: C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Devices\Client\System.Data.SqlClient.dll The file System.Data.SqlClient.dll does get deployed to my application directory, but there is no sign of dbnetlib.dll.

When I Google this Exception, I mainly get these suggestions:

  • This is a Microsoft bug, when Visual Studio 2005 and 2008 are installed. Resolve by (re)installing 'SQL Server Compact 3.5 Design Tools' http://support.microsoft.com/kb/945371.
    • I have Visual Studio 2008 and 2010 - AFAIK 2005 was never on my system. I tried un- and re-installing the SQL Server Compact 3.5 Design Tools (\WCU\SSCE\SSCEVSTools-enu.msi)
    • Edit: Since the Devices\Client-directory is installed by 'SQL Server Compact 3.5 for Windows Mobile' (SSCEDeviceRuntime-ENU.msi), I downloaded and also tried un- and re-installing the base version, SP1 and SP2, but there was still no deployment-difference.
  • Another suggestion is to install the SQL Client separately using a (platform-dependent) .cab (like sql.wce5.armv4i.CAB) and this dbnetlib.dll copied from e.g. C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Devices\Client\wce500\armv4i to a persistent start-up directory (like \Backup\Startup on this Datalogic).
    Without trying, I think this might even be limited to including this platform-dependent dbnetlib.dll, since System.Data.SqlClient.dll does get deployed.
    But this seems more like a a work around to me, deployment should take care of this. Drawback of this work around seems:
    • an install is executed at each cold boot (and maybe even at a warm boot)
    • adding (more) platform (and version) dependency to my project by explicitly defining the .cab

The question is: do you know a solution for Visual Studio to deploy correctly?
Another question might be: do you have an opinion about this work around?

(BTW: the DB-connection works fine on a Datalogic Memor WM (Windows Mobile), so I guess the appropriate .NET-library is already installed on that device.)

like image 415
Yahoo Serious Avatar asked Nov 04 '22 17:11

Yahoo Serious


1 Answers

Visual Studio generally does a good job of working out what to deploy, but it isn't fullproof. For example if the DLL is linked dynamically then it has no way of knowing that it is required and won't deploy it: it also routinely and silently fails to deploy files to the Windows directory.

I would recommend that you manually deploy the file during development. I generally prefer to do this anyway to make sure I know what has been deployed (the joy of batch files...).

like image 59
AAT Avatar answered Nov 12 '22 13:11

AAT