W
will
hi,
i'm trying to
(1)create a unmanaged c++ DLL
=============================================
extern "C" __declspec(dllexport) __cdecl int sum(int a,int b); ---->
compiled okay to mysum.dll
=============================================
(2)create a namespace/class to DllImport the above DLL
=============================================
using System.Runtime.InteropServices;
namespace ImportDLL
{
public class importdll
{
public importdll()
{
}
DllImport("mysum.dll",
EntryPoint="sum",ExactSpelling=false,CallingConvention=CallingConvention.Cdecl)]
public static extern int myfun(int a, int b);
}
}
=============================================
(3)create a aspx code behind
=============================================
using ImportDLL;
namespace TEST
{
...
...
...
public int my_result;
protected importdll imp = new importdll();
my_result = imp.myfun(1,1);
}
=============================================
when i run the aspx page, i got the following error:
CS0118: 'TEST.imp' denotes a 'field' where a 'class' was expected
error line is "content = imp.myfun(1,1);"
basically i want to call a c++ function which returns a value, which i
can subsequently assign to a variable. what have i done wrong?
thanks
will.
i'm trying to
(1)create a unmanaged c++ DLL
=============================================
extern "C" __declspec(dllexport) __cdecl int sum(int a,int b); ---->
compiled okay to mysum.dll
=============================================
(2)create a namespace/class to DllImport the above DLL
=============================================
using System.Runtime.InteropServices;
namespace ImportDLL
{
public class importdll
{
public importdll()
{
}
DllImport("mysum.dll",
EntryPoint="sum",ExactSpelling=false,CallingConvention=CallingConvention.Cdecl)]
public static extern int myfun(int a, int b);
}
}
=============================================
(3)create a aspx code behind
=============================================
using ImportDLL;
namespace TEST
{
...
...
...
public int my_result;
protected importdll imp = new importdll();
my_result = imp.myfun(1,1);
}
=============================================
when i run the aspx page, i got the following error:
CS0118: 'TEST.imp' denotes a 'field' where a 'class' was expected
error line is "content = imp.myfun(1,1);"
basically i want to call a c++ function which returns a value, which i
can subsequently assign to a variable. what have i done wrong?
thanks
will.