Création de DLL qui échoue
Bonjour à tous
J'ai sur visual studio 2010 suivi le training http://msdn.microsoft.com/en-us/library/ms235636(printer).aspx
Et tout marche sauf que dans mon dossier Debug je n'ai aucune DLL (mais des .tlog, des manifest.rc des pdb etc....
J'ai du rater un truc mais j'ai beau fouillé je ne trouve pas
Merci de m'aider...
j'ai quand j'appelle ma dll en C# via interrop ce message
Unable to find an entry point named 'Add' in DLL 'c:\\MathDll.dll
voila ma source :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| // MathFuncsDll.h
namespace MathFuncs
{
class MyMathFuncs
{
public:
static __declspec(dllexport) double Add(double a, double b);
};
} |
puis
mon .cpp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include "MathDll.h"
#include <stdexcept>
using namespace std;
namespace MathFuncs
{
double MyMathFuncs::Add(double a, double b)
{
return a + b ;
}
} |
et j'appelle avec ce code
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 29 30 31 32 33 34 35 36
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace testDLL
{
class Program
{
[DllImport("c:\\MathDll.dll")]
public static extern double Add(double a, double b);
static void Main(string[] args)
{
try
{
double myResult = Add(25, 56);
System.Console.WriteLine("Result {0}", myResult);
}
catch (Exception ex)
{
Console.WriteLine("errer" + ex.Message);
}
System.Console.WriteLine("end");
}
}
} |