Note that there are some explanatory texts on larger screens.

plurals
  1. PODllImport - function not returning the correct value in ASP.Net when deployed to IIS
    primarykey
    data
    text
    <p>I have a web service that I need to make a call to a function in some unmanaged code, I import the dll like:</p> <pre><code> class myClass { [DllImport("mydll.dll")] public static extern int FetchMyData(int DataType, int DataIndex); } </code></pre> <p>The web page does an AJAX callback to a WebService which calls the imported function like:</p> <pre><code> [WebMethod] public int FetchData(int IndexValue) { return myClass.FetchMyData(DATA_TYPE, IndexValue); } </code></pre> <p>When I run this from VisualStudio using the development IIS Express, everything works fine, and the function returns a positive integer. However, when I deploy to my local IIS, the function always returns -1. It doesn't even throw an exception which seems a bit odd.</p> <p>Things I have tried but didn't make any difference:</p> <ul> <li>added the "IIS AppPool\DefaultAppPool" to the parent directory with full permissions </li> <li>set the "Enable 32-Bit Applications" property to <strong>True</strong></li> </ul> <p><strong>EDIT</strong></p> <p>After further investigation and help from the various comments below it became clear that the issue here was not the function failing, rather a permissions related issue with what the dll function was doing, namely accessing a Memory Mapped File. I have created <a href="https://stackoverflow.com/questions/20363839/opening-a-memory-mapped-file-causes-filenotfoundexception-when-deployed-in-iis">this follow-up post</a> which replicates the core problem with sample code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload