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:
- I put the DLL in System32 and syswow64 folder.
- Gave full rights to ASPNET, IIS_WPG and IUSR (for that server) to the website bin directory and rebooted.
- Added the external DLL as existing items to the projects and set their "Copy to Output" property to "Copy Always".
- Published the app with target platform x86 as the dll is a 32 bit.
- I have IIS running on Integrated mode enable 32 bit.
- I put the dll in the \System32\Inetsrv directory
Below is a code snippet of how I call the dll
[HttpGet]
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
{
[DllImport("BS_SDK.dll",
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>
@Html.ValidationMessage("Error")
<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");
}).WithPaging(10).Sortable(true)
</div>
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)