Jan 06, 2006

RAPI EnumFiles error...

Recently, I was working with the Open .NET Compact Framework’s Desktop.Communication Library, writing a simple program to go through the device and show me all the files and directories below a certain starting point using the API’s RAPI.EnumFiles method.

Prior to adding the recursion, this program was working great. But once I added the recursion, the program began throwing a FatalExecutionEngineError exception usually at the EnumFiles method (but not always) and what was also interesting is the fact that it would sometimes recurse 10 directories and other times hundreds. The exact wording of the exception is as follows:

FatalExecutionEngineError was detected: The runtime has encountered a fatal error. The address of the error was at 0x7a0c6df2, on thread 0x1678. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

Googling over this error did not bring up very many useful results. However, I finally fell onto the post, FileInformation buffer size is too small. I downloaded the code, downloaded the RAPI.cs version 1.2, built the library, and viola! It appears to have solved my problem.

Filed In