Diagnosing a File Not Found error in a .NET application

2

I am using a .NET 4.0 application that is failing with a System.ComponentModel.Win32Exception exception. I've attached it to WinDBG to try and find out more.

...
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

After this point, the program will catch the exception and exit reporting that a file was not found. I do not have the source to this application. What can I do to figure out what file it is that the program is failing to find?

Thanks


EDIT

I've figured it out. I ended up setting Process Monitor to run while using WinDBG to break on the exception. That way the very last thing to in the ProcMon log should be the error. It was not. The very last thing in the ProcMon log was the program writing to a logfile in a temporary directory:

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

So, I opened that log file and sure enough, there was the files it was having trouble with.

>>>  [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)]

I don't know why those files aren't there (or even why it thinks they should be), but I do at least now know what files it was failing to find.

.net
exception
windbg
asked on Stack Overflow Jul 21, 2014 by PaulH • edited Jul 21, 2014 by PaulH

1 Answer

3

I would suggest using Process Monitor. You can monitor the files being accessed by your application and will be able to see files that are searched for but not found. Process Monitor has good filtering capability, so you can reduce the clutter of the diagnostics.

Note that this utility is useful for any Windows application, not just a .NET application.

answered on Stack Overflow Jul 21, 2014 by wageoghe

User contributions licensed under CC BY-SA 3.0