我有一个MVC4应用程序,它加载了一些DLL。基本上,MVC应用程序的体系结构是这样的:应用程序从用户接收一些作业,它从dll调用处理函数,最后将结果通过电子邮件发送给用户。
所有dll都是在64位上编译的,我在64位上使用IIS8,在Windows Server 2012R2和VS2013上。 当我运行/部署应用程序时,其行为是:
Scenario1
:从VS2013中的Visual Studio 2013运行,包括调试/发布模式中的Web服务器(IIS Express)=>工作正常Scenario2
:在发布模式下从部署在本地完整IIS8中的Visual Studio 2013运行=>工作正常Scenario3
:在本地完整IIS8中以发布模式部署并直接从浏览器运行,无需打开VS2013 => IIS与An unhandled win32 exception occurred in w3wp.exe.The Just-ln-Time debugger was launched without necessary security permissions. To debug this process, the Just-ln-Time debugger must be run as an Administrator.
崩溃当我打开调试器时,错误为:A heap has been corrupted
。在事件查看器中,日志为:
Faulting application name: w3wp.exe, version: 8.5.9600.16384, time stamp: 0x5215df96
Faulting module name: ntdll.dll, version: 6.3.9600.18821, time stamp: 0x59ba86db
Exception code: 0xc0000374
我知道异常代码0xc0000374来自Heap corruption
。
我使用DebugDiag和Application Verifier调试了IIS,并激活了Full PageHeap标志。 崩溃线程堆栈的相关部分是:
.NET Call Stack
mscorlib_ni!DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr)+68
[[InlinedCallFrame] (Microsoft.Win32.Win32Native.LocalFree)] Microsoft.Win32.Win32Native.LocalFree(IntPtr)
mscorlib_ni!System.Runtime.InteropServices.Marshal.FreeHGlobal(IntPtr)+2d
Species_DLL.Class1.Species_MetaModel()+b955
rIAMTestMVC4.Impressions.SpeciesUtil.use_Species_Integrated(Int32)+1efd
Full Call Stack
vrfcore!VerifierStopMessageEx+6f4
vrfcore!VfCoreRedirectedStopMessage+90
verifier!VerifierStopMessage+a0
verifier!AVrfpDphReportCorruptedBlock+2a7
verifier!AVrfpDphCheckNormalHeapBlock+c8
verifier!AVrfpDphNormalHeapFree+27
verifier!AVrfDebugPageHeapFree+af
ntdll!RtlDebugFreeHeap+47
ntdll!RtlpFreeHeap+74c85
ntdll!RtlFreeHeap+368
vrfcore!VfCoreRtlFreeHeap+1e
KERNELBASE!LocalFree+2e
mscorlib_ni!DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr)+68
[[InlinedCallFrame] (Microsoft.Win32.Win32Native.LocalFree)] Microsoft.Win32.Win32Native.LocalFree(IntPtr)
mscorlib_ni!System.Runtime.InteropServices.Marshal.FreeHGlobal(IntPtr)+2d
Species_DLL.Class1.Species_MetaModel()+b955
rIAMTestMVC4.Impressions.SpeciesUtil.use_Species_Integrated(Int32)+1efd
Scenario2和Scenario3之间有什么区别吗? VS是否有任何堆保护?
我也使用IIS7在Windows7上运行相同的方案,并且在所有三个方面都可以正常工作。
我无法访问DLL代码,但正如我所提到的,相同的代码在IIS7 / Windows7和Visual Studio的IIS8上运行完美。
LE:调用堆栈中显示了两个函数:
rIAMTestMVC4.Impressions.SpeciesUtil.use_Species_Integrated
=>此函数来自MVC控制器,它调用一个dll Species_DLL.Class1.Species_MetaModel
=>此函数来自dll,由前一个函数调用。如何解决scenario3的问题?这些情景之间有什么区别?
谢谢,
答案 0 :(得分:0)
我有类似的问题,但我通过将项目构建更改为x86来解决我的问题,以补偿32位。
答案 1 :(得分:0)
Did you run VS2013 as an administrator? if so, then this is what prevented the error from happening with VS, and happens with IIS only.
It looks like the IIS application pool is having a problem reaching those DLLs, and this problem didn't occur with VS2013.
Update: Just add the permission to the pool itself to access the folder:
x
in the "Enter the object
names to select:" text box. (Don't forget to change "DefaultAppPool"
here to whatever you named your application pool.)note: steps are copied with some changes from here.
To know or change the application pool that runs your application: when you open IIS manager and select your application from the tree on the left, find it in Advanced Settings down the Actions Pane on your right.
To change the identity of the pool , you'll find them under the machine in the tree on your left.
Check this article on how to specify the identity of the application pool.