![](/img/trans.png)
[英]What is causing my ASP.NET MVC app to stop emailing and recycling the app pool to immediately fix it?
[英]Unmanaged DLL in ASP.NET MVC app causes App pool to stop on IIS server
我的ASP.NET MVC应用程序使用用C ++编写的非托管外部DLL。
这个网站在Visual Studio中运行良好,正确定位和访问外部DLL。 但是,当网站发布在本地Web服务器(运行IIS 7.5)而不是Visual Studio IIS Express时,我收到以下错误:
HTTP Error 503. The service is unavailable.
外部DLL位于网站的bin目录中。看了IIS日志,我注意到每次调用dll时defaultapppool都会停止。
HTTP/1.1 GET /Bio/Select/3 503 1 Disabled DefaultAppPool
我尝试过以下方法:
下面是我如何调用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>
类似的问题包括无法在ASP.NET服务器上加载非托管DLL 如何在ASP.NET网站中调用非托管代码并将其托管在IIS中
当我在运行IIS 8的Web服务器上托管它时,我得到以下错误。所以可能在我的本地IIS服务器上它返回错误503因为它找不到dll但我还没有确定这个托管的我没有访问权限将dll复制到系统文件夹。
Unable to load DLL 'BS_SDK.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
为了找出你的应用程序搜索您的DLL,我建议微软FusionLog 。 它不仅会记录CLR搜索dll的位置,还会记录有关加载失败原因的更多详细信息。
此外,查看进程是否实际打开dll的文件句柄可能会有所帮助。 您可以通过Process Explorer找到:*下载ProcessExplorer并以管理员身份运行它。 *为“进程名称”添加过滤器并使用“w3wp.exe”*启动应用程序池*搜索“BS_SDK.dll”的进程资源管理器,您将看到它尝试加载它的目录。
我重新安装并重新安装了IIS,然后重复了问题中的所有步骤,它终于奏效了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.