DllImport, PInvoke et MissingMethodException
Bonjour à Tous,
Je viens vers vous pour avoir quelques éléments de réponse car j'ai un soucis que je n'arrive pas à résoudre malgré mes recherches (ici et ailleurs).
Je cherche à utiliser une dll Win32 sur PocketPC mais j'ai toujours l'erreur MissingMethodException : Can't find PInvoke DLL 'MyDll.dll'.
La dll a été copié avec l'exécutable (et sous le répertoire \windows aussi pour lever les doutes)
Voici le code source C# :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
using System.Reflection;
namespace test {
public partial class Form1 : Form {
[DllImport("MyDll.dll")]
public static extern int dll_getInteger();
public Form1() {
InitializeComponent();
textBox.Text = dll_getInteger().ToString();
}
}
} |
Voici le code source Delphi au cas où :
Code:
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
|
library MyDll;
{$R *.res}
function dll_getBool: boolean; stdcall;
begin
result := false;
end;
function dll_getString: PChar; stdcall;
var p : PChar;
begin
p := PChar('valeur');
result := p;
end;
function dll_getInteger : integer; stdcall;
begin
result := 1000;
end;
exports dll_getBool;
exports dll_getString;
exports dll_getInteger;
begin
end. |