Laden...

Dll-Import funktioniert bei einer WPF-Anwendung, bei KOnsole nicht mehr

Erstellt von Runshak vor 8 Jahren Letzter Beitrag vor 8 Jahren 1.271 Views
Thema geschlossen
R
Runshak Themenstarter:in
71 Beiträge seit 2014
vor 8 Jahren
Dll-Import funktioniert bei einer WPF-Anwendung, bei KOnsole nicht mehr

Hallo,

ich habe folgendes Problem...

Zwei Anwendungen einmal WPF einmal Konsole der Code ist copy/paste 1:1 identisch...

beim WPF funktioniert es einwandfrei bei der Konsole nicht...in beiden Fällen ist das Framework 4.0 und x86 eingestellt...importiert wird eine C++ Dll

public static class DLLCaller
   {
       [DllImport("CallSkalaFkt.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
       private static extern Int32 CallSkalaFkt_SkalaStart(Int32 _hWnd, string _DB_Path, string _GLOB_GUID, string _RG_PATH, Int32 _EE_ID, Int32 _EE_Par, Int32 new_Ring, Int32 _auto_Start, ref Int32 Status_Flag);

       public static string Call()
       {
           System.Threading.Thread.Sleep(1000);

           string _DB_Path = "D:\\Projekte\\Skala_Simu\\Simu\\Glob_Simu.mdb";
           string _GLOB_GUID = "{guid{5ACB1481-2692-4C66-8BBC-9CC8B9FDF0C2}}";
           string _RG_PATH = "D:\\Projekte\\Skala_Simu\\Simu\\";

           Int32 _hWnd = 0;
           Int32 _EE_ID = 1;
           Int32 _EE_Par = 0;
           Int32 new_Ring = 1;
           Int32 _auto_Start = 0;
           Int32 Status_Flag = 0;

           GCHandle m_gch = GCHandle.Alloc(Status_Flag, GCHandleType.Pinned);

           try
           {
               int tmp = CallSkalaFkt_SkalaStart(_hWnd, _DB_Path, _GLOB_GUID, _RG_PATH, _EE_ID, _EE_Par, new_Ring, _auto_Start, ref Status_Flag);
               m_gch.Free();
               return tmp.ToString();
           }
           catch (Exception ex)
           {
               return ex.Message;
           }
       }
   }

Der Fehler taucht auf, wenn das Programm in die erste Zeile des Try-Blocks springt...von dort gehts direkt in den Catch-Block ...Ergebnis ist> Fehlermeldung:

Eine externe Komponente hat eine Ausnahme ausgelöst ...Errorcode ist 0x80004005 E_FAIL => Unspecified error

gibt es noch andere Einstellungen auf die man achten sollte, beim Import einer DLL?

achso ich sollte noch hinzufügen, dass der selbe Fehler in einem neu erstellten WPF ebenfalls auftritt

Hinweis von Coffeebean vor 8 Jahren

Bitte beachte [Hinweis] Wie poste ich richtig? Punkt 6 und Punkt 3

849 Beiträge seit 2006
vor 8 Jahren
Warnung von Abt vor 8 Jahren

Dahingehend auch geschlossen.

Thema geschlossen