Nie można załadować biblioteki DLL 'CppWraper.dll'. Nie można odnaleźć określonego modułu. (Wyjątek od HRESULT: 0x8007007E).

0

Witam, Mam program, który był pisany w Visual Studio 2015. Jest to połączenie C# oraz C++. Teraz jak chce go odpalić na innym komputerze gdzie jest Visual Studio 2017 i pokazuje mi się taki komunikat (Załącznik).
Czy ktoś może mi pomóc w rozwiązaniu tego problemu?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ErgoPosnet
{

    public partial class Form1 : Form
    {
        // metoda importowana z naszej dll'ki CppWraper.dll
        [DllImport("CppWraper.dll", CallingConvention = CallingConvention.StdCall)]
        public static extern byte ZwrocDane(byte[] dane);


        private const int WM_DEVICECHANGE = 0x0219;
        //  private const int DBT_DEVICEARRIVAL = 0x8000; // A device or piece of media has been inserted and is now available.
        //   private const int DBT_DEVICEREMOVECOMPLETE = 0x8004; // A device or piece of media has been removed.


        private const int DBT_CONFIGCHANGECANCELED = 0x0019; // A request to change the current configuration (dock or undock) has been canceled.
        private const int DBT_CONFIGCHANGED = 0x0018; // The current configuration has changed, due to a dock or undock. 
        private const int DBT_CUSTOMEVENT = 0x8006;// A custom event has occurred.
        private const int DBT_DEVICEARRIVAL = 0x8000; // A device or piece of media has been inserted and is now available.
        private const int DBT_DEVICEQUERYREMOVE = 0x8001; // Permission is requested to remove a device or piece of media. Any application can deny this request and cancel the removal.
        private const int DBT_DEVICEQUERYREMOVEFAILED = 0x8002; // A request to remove a device or piece of media has been canceled.
        private const int DBT_DEVICEREMOVECOMPLETE = 0x8004; // A device or piece of media has been removed.
        private const int DBT_DEVICEREMOVEPENDING = 0x8003; // A device or piece of media is about to be removed. Cannot be denied.
        private const int DBT_DEVICETYPESPECIFIC = 0x8005; // A device-specific event has occurred.
        private const int DBT_DEVNODES_CHANGED = 0x0007; // A device has been added to or removed from the system.
        private const int DBT_QUERYCHANGECONFIG = 0x0017; // Permission is requested to change the current configuration (dock or undock).
        private const int DBT_USERDEFINED = 0xFFFF; // The meaning of this message is user-defined.


        //       protected override 
        protected override void WndProc(ref Message m)
        {
            //            LoggerLib.Logger log = new LoggerLib.Logger("log999.txt");                 // **** <<----  czy to jeszcze w ogole potrzebne ???
            //           log.write(m.ToString());
            switch (m.Msg)
            {
                case WM_DEVICECHANGE:
                    // The WParam value identifies what is occurring.
                    // n = (int)m.WParam;
                    if ((int)m.WParam == DBT_DEVNODES_CHANGED) // A device has been added to or removed from the system.
                    {
                        //MessageBox.Show("A device has been added to or removed from the system.");
                        //labelWykryto.Text = "";
                    }
                    else if ((int)m.WParam == DBT_DEVICEARRIVAL)
                    {
                      //  MessageBox.Show("A device or piece of media has been inserted and is now available.");
                        labelWykryto.Text = "attached";
                    }
                    else if ((int)m.WParam == DBT_DEVICEREMOVECOMPLETE)
                    {
                        labelWykryto.Text = "dettached";
                        //   MessageBox.Show("A device or piece of media has been removed.");
                    }
                    break;
            }
            base.WndProc(ref m);
        }

        public Form1()
        {
            string comparams = "COM4,9600,8,N,1,H";
            byte[] array = Encoding.ASCII.GetBytes(comparams);
            string ret = "";
            ret = Encoding.ASCII.GetString(array);
            InitializeComponent();
        }

        private void Pobierz_Click(object sender, EventArgs e)
        {
            try
            {

                Byte[] dane = new Byte[8 * 1024];
                Byte retCode = ZwrocDane(dane);
                if (retCode == 5)
                    labelWykryto.Text = "Error Opening device";
                else if (retCode == 2)
                    labelWykryto.Text = "Could not create a device.";
                else if (retCode == 4)
                    labelWykryto.Text = "Set Device Parameters ERROR";
                else
                    labelWykryto.Text = "ok";
                string ret = Encoding.ASCII.GetString(dane);
                richTextBox1.Text = richTextBox1.Text + ret + Environment.NewLine;
                richTextBox1.Text = richTextBox1.Text + "---------------------------------------" +  Environment.NewLine;
            }
            catch (Exception ex01)
            {
                MessageBox.Show(ex01.Message, ex01.Source);
            }


        }
    }


}

0

@Wyleskony nie wklejaj takiej masy kodu do posta skoro nie ma on znaczenia.

Błąd jest spowodowany tym, że Twoja dllka zostałą skompilowana razem z zależnością (inna dllką), której nie ma na maszynie na której próbujesz ją odpalić. Być może skompilowałeś ją w trybie zarządzalnym? Użyj Dependencies by poznać brakujące zależności Twojej dllki.

A jeśli nie chcesz niczego ściągać, instalować, to w VC\bin folder powinieneś mieć program pod tytułem dumbin, uruchom go w ten sposób

dumpbin /dependents CppWrapper.dll

żeby poznać zależności Twojej dllki.

0

Zainstalowałem ten program, ale nie wiem jak się z niego korzysta. Możesz mnie nakierować?
Po wrzuceniu mojego exe. Pojawiło mi się coś takiego.
screenshot-20181126190059.png

0

Po wrzuceniu mojego exe.

Raczej chodziło o potraktowanie tym programem DLL-ki.

Ale jeśli DLL-ka jest skompilowana pod Visualem 2015 to zapewne wymaga zainstalowanego Visual C++ Redistributable w tejże wersji.
https://support.microsoft.com/pl-pl/help/2977003

0

Pokazuje mi brak takiej dll. Gdzieś w necie ją znajdę i gdzie ją wrzucić? Pobrałem jakąś z internetu i wrzuciłem do SysWow64 oraz system32, ale to nie pomogło.
screenshot-20181126215852.png

1 użytkowników online, w tym zalogowanych: 0, gości: 1