Can not find PInvoke DLL kernel32.dll file C#

990 views Asked by At

I'm trying to conect my phone device vía USB to a server to transmit data.

I'm Working with RAPI, this is my code;

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
using OpenNETCF.Desktop.Communication;

I added the OpenNETCF.Desktop.Communication by following the next steps:

  1. In the Solution Explorer window, right-click the References folder. A pop-up menu displays.
  2. From the menu, select Add Reference.
  3. The Add Reference dialog box displays. Select the OpenNETCF.Desktop.Communication component.
  4. Click the OK button to add the selected component to your project.

And this is my code:

     private void BTN_LEVANTAMIENTO_Click(object sender, EventArgs e)
     {
            try
            {
                RAPI myrapi = new RAPI(); //Is it Okay?
                myrapi.Connect();
                while (!myrapi.DevicePresent)
                {
                    MessageBox.Show("Please connect your device to your PC using ActiveSync and before clicking the OK button.",
                      "No Device Present");
                    //myrapi.Connect();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("The following error occurred while attempting to connect to" + " your device - " + ex.Message,
                  "Connection Error");
                Application.Exit();
            } 

The problem it shows me is

"No se puede encontrar el archivo DLL PInvoke kernel32.dll c#"

Any idea about what could I do?

1

There are 1 answers

1
bnem On

You should use RAPI2 instead. RAPI2 replaces RAPI.