LoadIFilter() returns -2147467259 for some PDF files

删除回忆录丶 提交于 2019-12-07 07:49:35

问题


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?


回答1:


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




回答2:


Here's how I solved it:

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




回答3:


To get around the E_FAIL for Adobe 10.x, please see https://stackoverflow.com/a/8841476/455322




回答4:


I got the same result when running LoadIFilter until I found this post which pointed me to the solution:

Make sure that your build platform target is x86 and avoid running the application from within Visual Studio.

Also, if you can move your code that interacts with the IFilter into a separate .exe application with the name filtdump.exe, you will simplify your code considerably.



来源:https://stackoverflow.com/questions/690076/loadifilter-returns-2147467259-for-some-pdf-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!