诊断.NET应用程序中的“找不到文件”错误

时间:2014-07-21 13:56:08

标签: .net exception windbg

我正在使用失败时出现System.ComponentModel.Win32Exception异常的.NET 4.0应用程序。我已将它附加到WinDBG以尝试查找更多内容。

...
0:000> sxe clr
0:000> g
...
(17c0.664): CLR exception(17c0.664): CLR exception - code e0434352 (first chance)
 - code e0434352 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00c5eb78 ebx=00000005 ecx=00000005 edx=00000000 esi=00c5ec3c edi=00000001
eip=74a31d4d esp=00c5eb78 ebp=00c5ebd0 iopl=0         nv up ei pl nz ac pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000216
KERNELBASE!RaiseException+0x48:
74a31d4d 8b4c2454        mov     ecx,dword ptr [esp+54h] ss:002b:00c5ebcc=b5cf3745
0:000> .loadby sos clr
0:000> !pe
Exception object: 0298aed0
Exception type:   System.ComponentModel.Win32Exception
Message:          Message:          The system cannot find the file specified

InnerException:   InnerException:   <none>
<none>
StackTrace (generated):
<none>
StackTraceString: StackTraceString: <none>
<none>
HResult: 80004005

在此之后,程序将捕获异常并退出报告未找到文件。我没有这个应用程序的来源。 我该怎么做才能找出程序找不到的文件?

由于


修改

我已经弄清楚了。我最终设置了Process Monitor来运行,而使用WinDBG来打破异常。这样,ProcMon日志中的最后一件事应该是错误。它不是。 ProcMon日志中最后一件事是程序写入临时目录中的日志文件:

CloseFile    C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\windows\INF\setupapi.offline.log

所以,我打开了那个日志文件,果然,有文件遇到了麻烦。

>>>  [Import Driver Package - C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\import\kmdf.inf]
>>>  Section start 2014/07/21 09:21:49.104
       os: Version = 6.3.9600, Service Pack = 0.0, Suite = 0x0100, ProductType = 1, Architecture = x86
      cmd: "C:\project\MSM8974\trunk\wpk\Windows Phone Kits\8.1\Tools\bin\i386\pkggen.exe" kmdf.pkg.xml /version:1.0.0.0 /build:fre /cpu:ARM /config:"C:\project\MSM8974\trunk\wpk\Windows Phone Kits\8.1\Tools\bin\i386\pkggen.cfg.xml" /output:. /variables:"HIVE_ROOT=C:\project\MSM8974\trunk\wpk\Windows Phone Kits\8.1\CoreSystem" +diagnostic
     sto: Driver Store   = C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\windows\System32\DriverStore (6.3.9651)
     sto: Driver Package = C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\import\kmdf.inf
     sto: Architecture   = arm
     sto: Flags          = 0x00001B0F
     inf: Class GUID     = {78a1c341-4539-11d3-b88d-00c04fad5171}
     inf: Driver Version = 07/18/2014,14.10.59.893
     inf: Catalog File   = kmdf.cat
     inf: Version Flags  = 0x00000011
     inf: {Query Configurability: C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\import\kmdf.inf} 09:21:49.118
     inf:      Driver package uses WDF.
     inf:      Driver package 'kmdf.inf' is configurable.
     inf: {Query Configurability: exit(0x00000000)} 09:21:49.122
     flq: Copying 'C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\import\kmdf.inf' to 'C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\windows\System32\DriverStore\FileRepository\kmdf.inf_arm_b057bd3ebf229833\kmdf.inf'.
     flq: Copying 'C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\import\kmdf.sys' to 'C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\windows\System32\DriverStore\FileRepository\kmdf.inf_arm_b057bd3ebf229833\kmdf.sys'.
!!!  flq: Error installing file (0x00000002)
!!!  flq: Error 2: The system cannot find the file specified.
!    flq:      SourceFile   - 'C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\import\WdfCoInstaller01011.dll'
!    flq:      TargetFile   - 'C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\windows\System32\DriverStore\FileRepository\kmdf.inf_arm_b057bd3ebf229833\WdfCoInstaller01011.dll'
!!!  cpy: Failed to copy file 'C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\import\WdfCoInstaller01011.dll' to 'C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\windows\System32\DriverStore\FileRepository\kmdf.inf_arm_b057bd3ebf229833\WdfCoInstaller01011.dll'. Error = 0x00000002
!!!  flq: SPFQNOTIFY_COPYERROR: returned SPFQOPERATION_ABORT.
!!!  flq: Error 995: The I/O operation has been aborted because of either a thread exit or an application request.
!!!  flq: FileQueueCommit aborting!
!!!  flq: Error 995: The I/O operation has been aborted because of either a thread exit or an application request.
!!!  sto: Failed to copy driver package to 'C:\Users\username\AppData\Local\Temp\4g0azgzu.y4p\windows\System32\DriverStore\FileRepository\kmdf.inf_arm_b057bd3ebf229833'. Error = 0x00000002
!!!  sto: Failed to import driver package into Driver Store. Error = 0x00000002
<<<  Section end 2014/07/21 09:21:49.192
<<<  [Exit status: FAILURE(0x00000002)]

我不知道为什么那些文件不在那里(甚至为什么它认为它们应该是),但我至少现在知道它找不到哪些文件。

1 个答案:

答案 0 :(得分:3)

我建议使用Process Monitor。您可以监视应用程序正在访问的文件,并且可以查看搜索但未找到的文件。 Process Monitor具有良好的过滤功能,因此您可以减少诊断的混乱。

请注意,此实用程序对任何Windows应用程序都很有用,而不仅仅是.NET应用程序。