I'm calling native code dll (delphi) procedure(parameterless) from asp.net app and getting 'Access violation reading location' exception from iisexpress.exe for that [name].dll. Code works perfectly fine in Windows forms app.
delphi dll native code:
procedure test() stdcall;
begin
end;
exports
test;
Asp.net c# code calling DLL(not working):
[DllImport("name.dll", CharSet = CharSet.Unicode,
CallingConvention = CallingConvention.StdCall)]
public static extern void test();
protected void Page_Load(object sender, EventArgs e)
{
test();
}
Winforms.net c# working code calling same DLL:
[DllImport("name.dll", CharSet = CharSet.Unicode,
CallingConvention = CallingConvention.StdCall)]
public static extern void test();
private void button3_Click(object sender, EventArgs e)
{
test();
}
Exception I'm getting for asp.net app: Exception thrown at 0x000000000040D289 (name.dll) in iisexpress.exe: 0xC0000005: Access violation reading location 0x000002756568CCB0.
Looks like it has something to do with IIS since it is working on Winforms app perfectly, but I'm not sure what.
What I have tried:
I've checked for possible windows Bitness issue. Dll is built under win64. Asp Web app and iis express settings are also set to x64 from app properties. Parameter type incompatibility is ruled out, because the procedure is parameterless and it is not returning anything either. I also gave 'Everyone' all permissions to the dll. The same code of calling same dll works in .net Windows forms application. It is not working on Windows server IIS either.