Autor Beitrag
Xzeer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62



BeitragVerfasst: Sa 05.12.09 18:13 
Hallo,

ich versuche, bisher leider ohne Erfolg, eine DLL einzubinden und deren Methoden zu übernehmen.

Die DLL hängt unten an.

Der akuelle Versuch:

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace USBBoardTest
{
    public partial class Form1 : Form
    {

        [DllImport("K8055D_C.dll")]
        public static extern int OpenDevice(long CardAddress);

        [DllImport("K8055D_C.dll")]
        public static extern void CloseDevice();

        [DllImport("K8055D_C.dll")]
        public static extern void SetDigitalChannel(long Channel);

        [DllImport("K8055D_C.dll")]
        public static extern void ClearDigitalChannel(long Channel);

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenDevice(0);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            CloseDevice();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            SetDigitalChannel(1);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            ClearDigitalChannel(1);
        }
    }
}


Und der Fehler:
Fehler

Wär echt klasse, wenn mir da wer helfen könnte.
Ich vermute das es einen Konfik der Datentypen ist, weiß aber nicht, wie ich in die DLL reinschauen kann und anschließend das Problem bei mir im Projekt beheben kann.

Es gibt hier auch noch eine Projektseite des Boards und der DLL.

Moderiert von user profile iconChristian S.: Inline-Anhang auch inline eingefügt ;-)
Einloggen, um Attachments anzusehen!
_________________
Xzeer
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Sa 05.12.09 18:22 
Hallo,

als erstes empfiehlt es sich doch, die angegebene BadImageFormatException auszuwerten. Dabei ist ex.ToString immer ausführlicher als ex.Message; auch ex.InnerException ist oft hilfreich.

Wie in der SDK-Doku/MSDN/Hilfe unter "Hinweise zu dieser Klasse" zu lesen ist, bringen die Angaben, die in den Konstruktoren angegeben werden können und dann in der Exception auftauchen, Hinweise auf das konkrete Problem.

Gruß Jürgen
Xzeer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62



BeitragVerfasst: Sa 05.12.09 18:32 
also bei ex.tostring() kommt das:

ExToString

Moderiert von user profile iconChristian S.: Inline-Anhang auch inline eingefügt ;-)
Einloggen, um Attachments anzusehen!
_________________
Xzeer
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Sa 05.12.09 20:09 
Ich rate mal, es ist eine x86-Dll und du hast ein x64-OS? Dann musst du auch in den Projekteigenschaften als Platform x86 eintragen.

_________________
>λ=
Xzeer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62



BeitragVerfasst: Sa 05.12.09 20:45 
da kannst du richtig liegen, aber wie stelle ich auf x86 um?

_________________
Xzeer
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Sa 05.12.09 21:20 
Projekteigenschaften -> Erstellen -> Zielplattform

_________________
>λ=
Xzeer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62



BeitragVerfasst: So 06.12.09 14:33 
Hey, danke Kha. Funktioniert jetzt einwandfrei. :D

_________________
Xzeer