“Can't find PInvoke DLL 'dbnetlib.dll'.” error in Smart Device Application

*爱你&永不变心* 提交于 2019-12-02 05:36:17

问题


I am creating a program in Visual Studio Pro 2008, and I am trying to access a SQL database from my program. The device that is running the program is running on Windows CE, and it is a bar code scanner. When I run the code and try to establish a connection to the database, I get thrown a MissingMethodExeption which says:

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

From reseraching online, I found out that you need to instal the sql.ppc.we5.armv4i.cab file, however my device isn't installing it (One of my problems).

Here is the code I am using to establish a connection with my SQL database.

 string conString = "Data Source=OS4DPC05\\SQLEXPRESS;Initial Catalog=testing;Integrated Security=SSPI;User ID=**************;";
 Process.Start("\\windows\\wceload.exe", "'\\Program Files\\SmartDeviceProject2\\sql.ppc.wce5.armv4i.cab'");
        using (SqlConnection con = new SqlConnection(conString))
        {
            con.Open();
        }

That is just part of the code, but the program always stops at con.Open();

Anyone know how to fix this problem? Any suggestions would be much appreciated.


回答1:


The way I solved my problem was I found dbnetlib.dll on my computer and I placed it in the same folder where my application was running from. There was more than one so I kept copying the different versions till I found the right one.




回答2:


Copying the sql.ppc.we5.armv4i.cab will not resolve the problem.

The problem is that a bug in Visual Studio does not include dbnetlib.dll in the list of dependencies to be copied to the device. I have resorted to adding the appropriate dbnetlib.dll file from the EMDK (motorola Wt41N0 in my case) armv4 directories directly to the VS project and setting it to copy always to ensure it ends up in the build.

Your device is different but there should be a version of dbnetlib.dll somewhere under your SDK directory for your device processor type.




回答3:


Faced the same issue when trying to connect from a Windows Compact Edition 7 device to an Sql Server 2014 instance.

I am using Visual Studio 2008 as it is the latest version to support smart devices (the device type of Windows CE 7). So I did a search for dbnetlib.dll on the computer and chose the one from the armv4i directory:

I copied that dll in the same directory where my application is located on the target device and the app works fine since then.




回答4:


I built a project in VS2008 for Win CE6.5 handheld devices, and they had no problem connecting to ms sql.

Now I got new Win CE 7.0 devices, and all of a sudden I am getting this message while running that same project.

Turns out that Windows folder in my new WinCE7.0 handheld device was missing the dbnetlib.dll file.

So I copied the file from my WinCE6.5 device into the Windows folder of the new WinCE7.0 device - and it works perfectly fine.




回答5:


Just copy from your pc dbnetlib.dll and paste it to ur device application stored folder where your cab file install after run.



来源:https://stackoverflow.com/questions/21838161/cant-find-pinvoke-dll-dbnetlib-dll-error-in-smart-device-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!