我的ASP.NET MVC应用程序使用用C++编写的非托管外部DLL。ASP.NET MVC应用程序中的非托管DLL导致App池在IIS服务器上停止
本网站在Visual Studio中正常运行,正确定位和访问外部DLL。然而,当网站上的一个本地的网络服务器发布(运行IIS 7.5),而不是在Visual Studio IIS表达我得到以下错误:
HTTP Error 503. The service is unavailable.
外部DLL位于website.On的bin目录看看IIS日志我注意到,每次我调用dll时,都会停止defaultapppool。
HTTP/1.1 GET /Bio/Select/3 503 1 Disabled DefaultAppPool
我曾尝试以下:
- 我把在System32中和Syswow64资料夹中的DLL。
- 将ASPNET,IIS_WPG和IUSR(对于该服务器)的权限授予网站bin目录并重新启动。
- 将外部DLL作为现有项目添加到项目中,并将其“复制到输出”属性设置为“始终复制”。
- 用目标平台x86发布应用程序,因为dll是32位。
- 我有集成模式启用32位IIS上运行。
- 我把DLL中\ System32 \ Inetsrv目录
下面是我如何调用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();
}
我的观点
@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>
类似的问题,包括代码段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
当我托管于Web服务器运行IIS 8,我得到了下面error.So也许我的本地IIS服务器返回503错误怎么把它无法找到该dll,但我还没有决定以此为托管的一个我没有访问权限将dll复制到系统文件夹。
Unable to load DLL 'BS_SDK.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
在服务器内,应用程序日志中应包含更详细的错误。你是否看过并发布详细信息? – 2015-03-25 06:35:31
您是否在应用程序池中使用.net框架客户端配置文件? – User2012384 2015-03-25 06:54:03
@MitchelSellers你指的是哪些日志?你能否指示我在应用程序日志位置? – GotaloveCode 2015-03-25 08:11:27