Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
Delphi
procedure test() stdcall;
begin       
end;

exports 
test;


Asp.net c# code calling DLL(not working):
C#
[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:
C#
[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.
Posted
Updated 23-Oct-19 20:16pm
v2
Comments
Richard MacCutchan 24-Oct-19 3:10am    
Are you sure that all the appropriate Delphi system support libraries are installed on the server?
Kornfeld Eliyahu Peter 27-Oct-19 10:53am    
The user context under which the web application runs probably different from that of the WinForm application...
Maybe you try to access a DLL outside your web application's folder?
Try put it in the bin folder you have...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900