views:

499

answers:

2

I am trying to use Adobe IFilter to search PDF files. My code is written in C# and I am using p/invoke to get an instance of IFilter:

    [DllImport("query.dll", SetLastError = true, CharSet = CharSet.Unicode)]
    private extern static int LoadIFilter(
        string pwcsPath,
        [MarshalAs(UnmanagedType.IUnknown)] object pUnkOuter,
  ref IFilter ppIUnk);

This works for most PDF files except a few for which this method returns -2147467259 and ppIUnk is coming as null. Does anyone have this type of errors or have any suggestions of how to figure this out?

+2  A: 

See the MSDN docs for the LoadIFilter function - you should be getting one of the error codes, at least according to that page.

  • E_ACCESSDENIED = 0x80070005 - The function was denied access to the filter file.
  • E_HANDLE = 0x80070006 - The function encountered an invalid handle, probably due to a low-memory situation.
  • E_INVALIDARG = 0x80070057 - The function received an invalid parameter.
  • E_OUTOFMEMORY = 0x8007000E - The function did not have sufficient memory or other resources to complete the operation.
  • E_FAIL = 0x80000008 - The function encountered an unknown error.

(Also, the full set of constant values is listed here, which seems to be rather longer than that listed on MSDN.) Now, the interesting things is, your error code corresponds to 80004005 in hex, which isn't listed on either or those pages. I'm suspecting pinvoke.net may have it wrong however, as many other sites (this for example) list it as E_FAIL... not that it really helps anyway. Sorry for the inconclusive answer, but maybe it will point you along the right track at least.

Edit: This error seems to have been documented elsewhere and caused much confusion to many people, with no simple solution. It seems like the cause could be one of several in fact... There's various suggestions here and here that you may want to try, but I don't think I can help you any more than that, as I have never encountered this error myself in this context. Good luck anyway...

Noldorin
A: 

Here's how I solved it:

Uninstall Adobe Reader/Acrobat. Install the latest version (again). It should fix the pdf filters. Good luck.

peerLAN