Unmanaged DLL in ASP.NET MVC app causes App pool to stop on IIS server


My ASP.NET MVC App uses an unmanaged external DLL written in C++.

This website runs fine from within Visual Studio, locating and accessing the external DLLs correctly. However, when the website is published on a local webserver (running IIS 7.5) rather than the Visual studio IIS Express I get the following error:

HTTP Error 503. The service is unavailable.

The external DLL is located in the bin directory of the website.On having a look at the IIS logs I noticed the defaultapppool stops everytime I call the dll.

HTTP/1.1 GET /Bio/Select/3 503 1 Disabled DefaultAppPool

I have tried the following:

  1. I put the DLL in System32 and syswow64 folder.
  2. Gave full rights to ASPNET, IIS_WPG and IUSR (for that server) to the website bin directory and rebooted.
  3. Added the external DLL as existing items to the projects and set their "Copy to Output" property to "Copy Always".
  4. Published the app with target platform x86 as the dll is a 32 bit.
  5. I have IIS running on Integrated mode enable 32 bit.
  6. I put the dll in the \System32\Inetsrv directory

Below is a code snippet of how I call the dll

    public ActionResult Select(int ID)
        int res = BSSDK.BS_InitSDK();
        if (res != BSSDK.BS_SUCCESS)
           ModelState.AddModelError("Error", "SDK failed to initialise");
        return View()

   public class BSSDK
        CharSet = CharSet.Ansi,
        EntryPoint = "BS_InitSDK")]
    public static extern int BS_InitSDK();

My view

@model IEnumerable<BasicSuprema.Models.BioUser>

@using GridMvc.Html
    ViewBag.Title = "Bio Users On DB";
<div class="well well-sm"><h3>@ViewBag.Title</h3></div>
<div class="grid-wrap">
    @Html.Grid(Model).Named("UsersGrid").Columns(columns =>
                        columns.Add(c => c.BioUserID).Titled("ID");
                        columns.Add(c => c.UserName).Titled("User");



Similar questions include Unmanaged DLLs fail to load on ASP.NET server How to call unmanaged code in ASP.NET website and host it in IIS

Unable to call the DLL from ASP.NET

When I hosted it on web server running IIS 8 I get the below error.So maybe on my local IIS server it returns error 503 coz it can't find the dll but am yet to determine this as for the hosted one I dont have access to copy the dll to the system folders.

Unable to load DLL 'BS_SDK.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
asked on Stack Overflow Mar 25, 2015 by GotaloveCode • edited May 23, 2017 by Community

2 Answers


In order to find out where your application searches for your dll, I recommend Microsoft FusionLog. It will not only log where the CLR searches for dlls, it will also log more details on why loading failed.

Additionally, it might be helpful to see if the process actually opens a file handle for the dll. You can find out via Process Explorer: * Download ProcessExplorer and run it as administrator. * Add a filter for 'Process Name' and use 'w3wp.exe' * Start up your application pool * Search process explorer for 'BS_SDK.dll' and you will see from which directory it tried to load it.

answered on Stack Overflow Mar 30, 2015 by chrisn

I uninstalled and installed IIS afresh then repeated all the stated steps in the question and it finally worked.

answered on Stack Overflow Mar 27, 2015 by GotaloveCode

User contributions licensed under CC BY-SA 3.0