none
iisexpress.exe: Access violation reading location when calling native code DLL in web app only RRS feed

  • Question

  • 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.

    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.

    delphi dll native code:

    procedure test() stdcall;
    begin       
    end;
    
    exports 
      test;

    Asp.net c# code calling DLL:

    [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.

    Thanks

    • Moved by CoolDadTx Friday, October 25, 2019 1:50 PM ASP.NET related
    Thursday, October 24, 2019 5:58 AM

All replies

  • IIS Express is a development server, and it's not local IIS on your development computer, which is the real IIS. I suggest that you try to use local IIS not IIS Express and see if the problem follows. Of course,  you would have to install IIS on the computer. 

    https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-enable-debugging-for-aspnet-applications?view=vs-2017

    Thursday, October 24, 2019 7:28 AM
  • Hi Levani82,

    Thank you for posting here.

    Since this thread is related to delphi dll and asp.net and the problem is maybe related to Asp.net. Therefore, I suggest that you could post it in the Asp.net forum.

    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, October 25, 2019 6:00 AM