LKeene
Thanks Peter, but before I can try that I thought I'd make sure I've got the interop mechanism"working" so I wrote a dead-simple Dll to test things and, for some reason, I just can't get it to work.Here's what I've done:
In VC++ 2005 I created a non-MFC Win32 app, chose "Dll" as the application type and checked the "Empty project" check box. I created a new header file consisting solely of the following (modeled closely after code I found in a book):
#ifndef __MYLOUSYDLL_H
#define __MYLOUSYDLL_H
#ifndef __MYLOUSYDLL__
#define __MYLOUSYDLLLIB__ __declspec(dllimport)
#else
#define __MYLOUSYDLLLIB__ __declspec(dllexport)
#endif
__MYLOUSYDLLLIB__ int MathTest(int val);
#endif
My source file consists solely of the following:
#define __MYLOUSYDLL__
#include "MyLousyDll.h"
__MYLOUSYDLLLIB__ int MathTest(int val)
{
//Do some serious number crunching:
return (val+10);
}
I then created a little test app in c++ to test this by Including the header, linking to the .lib file and putting the .dll file in the .exe directory of the test app and calling the function. Everything worked fine. Then it was time to test it from C#. I created a new C# dialog app with a button on it. In my form.cs I have:
public partial class Form1 :Form
{
[DllImport("MyLousyDll.dll")]
private static extern int MathTest(int val);
.
.
.
private void button1_Click(object sender, EventARgs e)
{
int NewVal = MathTest(1);
}
That's it. I copy the Dll file into the folder containg the c# executable and run. It compiles but I get a runtime exception at the function call claiming "Unable to find an entry point named "MathTest" in dll "MyLousyDll.dll". The strange thing is that it worked fine in C++. Any ideas what might be going on here As always,thanks everyone!