ASP.NET 2.0应用程序在IIS 5隔离模式下在Win 2003上运行,但在(默认)IIS 6模式下不运行

时间:2008-09-30 18:03:27

标签: asp.net iis-6 unmanaged dllimport

该应用使用DLLImport来调用旧的非托管dll。我们为了这个问题而调用这个dll Unmanaged.dll。 Unmanaged.dll依赖于其他5个传统dll。所有遗留的dll都放在我的ASP.NET应用程序的WebApp / bin /目录中。

当IIS在5.0隔离模式下运行时,应用程序正常工作 - 对旧版dll的调用处理没有错误。

当IIS以默认的6.0模式运行时,应用程序可以启动Unmanaged.dll(InitMe()),但在稍后调用它时会消失(ProcessString())。

我正把头发拉出来。我已经将非托管dll移动到了不同的位置,尝试了各种安全设置,并且长时间难以搜索解决方案。救命啊!

示例代码:

[DllImport("Unmanaged.dll", EntryPoint="initME", CharSet=System.Runtime.InteropServices.CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
    internal static extern int InitME();
//Calls to InitMe work fine - Unmanaged.dll initiates and writes some entries in a dedicated log file
[DllImport("Unmanaged.dll", EntryPoint="processString", CharSet=System.Runtime.InteropServices.CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
    internal static extern int ProcessString(string inStream, int inLen, StringBuilder outStream, ref int outLen, int maxLen);
//Calls to ProcessString cause the app to crash, without leaving much of a trace that I can find so far

更新

从小型转储中取出一个堆栈。似乎是一个堆栈溢出,但我想知道更多,如果有人可以帮助我。加载了sos.dll的WinDbg中“kb”的结果:

1beb51fc 7c947cfb 7c82202c 00000002 1beb524c ntdll!KiFastSystemCallRet  
1beb5200 7c82202c 00000002 1beb524c 00000001 ntdll!NtWaitForMultipleObjects+0xc  
WARNING: Stack unwind information not available. Following frames may be wrong.  
1beb52a8 7c822fbe 00000002 1beb52ec 00000000 kernel32!WaitForMultipleObjectsEx+0xd2  
1beb52c4 7a2e1468 00000002 1beb52ec 00000000 kernel32!WaitForMultipleObjects+0x18  
1beb5308 7a2d00c4 7a0c3077 1bc4ffd8 1bc4ffd8 mscorwks!CreateHistoryReader+0x19e9d  
1beb531c 7a0c312f 7a0c3077 1bc4ffd8 888d9fd9 mscorwks!CreateHistoryReader+0x8af9  
1beb5350 7a106b2d 1b2733a0 00000001 1b2733a0 mscorwks!GetCompileInfo+0x345ed  
1beb5378 7a105b91 1b272ff8 1b2733a0 00000001 mscorwks!GetAddrOfContractShutoffFlag+0x93a8  
1beb53e0 7a105d46 1beb5388 1b272ff8 1beb5520 mscorwks!GetAddrOfContractShutoffFlag+0x840c  
1beb5404 79fe29c5 00000001 00000000 00000000 mscorwks!GetAddrOfContractShutoffFlag+0x85c1  
1beb5420 7c948752 1beb5504 1beef9b8 1beb5520 mscorwks!NGenCreateNGenWorker+0x4d52  
1beb5444 7c948723 1beb5504 1beef9b8 1beb5520 ntdll!ExecuteHandler2+0x26  
1beb54ec 7c94855e 1beb1000 1beb5520 1beb5504 ntdll!ExecuteHandler+0x24  
1beb54ec 1c9f2264 1beb1000 1beb5520 1beb5504 ntdll!KiUserExceptionDispatcher+0xe  
1beb57f4 1c92992d 1beb6e28 1db84d70 1db90e28 Unmanaged1!UMgetMaxSmth+0x1200ad  
1beb5860 1c929cfe 00000000 1db84d70 1beb6e28 Unmanaged1!UMgetMaxSmth+0x57776  
1beb58c0 1c930b04 00000000 1db84d70 1beb6e28 Unmanaged1!UMgetMaxSmth+0x57b47  
1beb5924 1c99d088 00000000 1db84d70 1beb6e28 Unmanaged1!UMgetMaxSmth+0x5e94d  
1beb5990 1c99c955 00000000 1beb6e28 1beb6590 Unmanaged1!UMgetMaxSmth+0xcaed1  
1beb5a44 1c99e9ae 00000000 40977000 1db90e28 Unmanaged1!UMgetMaxSmth+0xca79e  

4 个答案:

答案 0 :(得分:1)

解决方案: 创建一个新线程,在其中运行导入的dll,为其堆栈分配更多内存。

答案 1 :(得分:0)

给出的错误是什么?如果应用程序真的崩溃了,你可能不得不进入Windows事件日志来获取错误的堆栈跟踪。

答案 2 :(得分:0)

我运行了procmon,debugdiag,尝试使用microsoft调试工具。每次应用程序崩溃时,Dr.Watson都会创建一对文件 - .dmp和.tmp(我试图调试但没有成功)。

以下是事件日志中的错误:

事件类型:错误
事件来源:.NET Runtime 2.0错误报告
活动类别:无
事件代码:1000
日期:2008年9月30日 时间:16:13:38
用户:不适用
电脑:APPLICATIONTEST010
说明:
错误应用程序w3wp.exe,版本6.0.3790.3959,邮票45d6968e,错误模块Unmanaged1.dll,版本0.0.0.0,邮票48b6bfb8,调试? 0,故障地址0x00122264。

答案 3 :(得分:0)

我认为在这里寻找的一个潜在问题是你的DLL可以在调用InitME和ProcessString之间被运行时卸载 - 所以如果ProcessString依赖于首先被调用的InitME,它可能会“繁荣”。

解决方法是使用旧的LoadLibrary和FreeLibrary强制运行时在这两个函数的调用之间加载库。不需要GetProcAddress(据我所知)。