Hello,
I got a C++ dll which has to be integrated in a C# project.
I think I found the correct way to do it, but calling the dll gives me this error: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
This is the function in the dll:
extern long FAR PASCAL convert (LPSTR filename);
And this is the code I'm using in C#
namespace Test{
public partial class Form1 : Form
{
[DllImport("convert.dll", SetLastError = true)]
static extern Int32 convert([MarshalAs(UnmanagedType.LPStr)] string filename);
private void button1_Click(object sender, EventArgs e)
{
// generate textfile
string filename = "testfile.txt";
StreamWriter sw = new StreamWriter(filename);
sw.WriteLine("line1");
sw.WriteLine("line2");
sw.Close();
// add checksum
Int32 ret = 0;
try
{
ret = convert(filename);
Console.WriteLine("Result of DLL: {0}", ret.ToString());
}
catch (Exception ex)
{
lbl.Text = ex.ToString();
}
}
}}
Any ideas on how to proceed with this?
Thanks a lot, Frank