tags:

views:

361

answers:

3

Is there a way to know that a call to TextReader.Read or TextReader.ReadToEnd call will hang without throwing exeption before I do the call?


try
{
 using (var filterReader = new EPocalipse.IFilter.FilterReader(tempFileName))
 {
  mediaContent = filterReader.ReadToEnd();
 }
}
catch (Exception e)
{
 Log.Error("DealerPortalIndex Error on file: " + tempFileName, e, this);
 mediaContent = string.Empty;
}

filterReader.ReadToEnd() hangs and never throws exception on a certain .xls file (maybe more file)

I have also tried using a filterReader.Read(char{}, int, int) to read block and get the same problem.

+6  A: 

(You say textreader in your code, but the example is using EPocalips IFilter module.)

I think it's a bug in EPocalipse IFilter. I don't know how updated their code is, but I recall something to the same effect some years ago when I was working with IFilters and used the EPocalipse code.

You should run it in the debugger and break the code to see where in the EPocalipse library it's hanging. Most likely it's stuck in a loop.

[Edit] I found my old updated code and put it up on skydrive (Epocalipse.IFilter.zip). See if it solves your problems. It has detection for infinite IFilter parse loops, and excel files with locked cells.

Mikael Svenson
I have downloaded the code, built, and added dll to replace mine. Now it is hanging the workerprocess on the very first pdf it hits. I am not asking for support for the code example. I appreciate your help. Just FYI.
mbalkema
It's been some time since I used this code so it might fail :) Which PDF IFilter do you use, and any way I can get a copy of the file to test? And did you test the code on your problematic excel file?
Mikael Svenson
I ended up using a blend of the code you posted and the code I already had. I mostly just used the extra checks for filter return codes and infinate loops and throwing exceptions. Thanks again for your help. I am now indexing 5000+ documents of assorted types successfully.
mbalkema
thanks for your help Mikael... we struggled with this for hours yesterday. (I work with mbalkema)
Anthony Shaw
Glad I could help :)
Mikael Svenson
A: 

Hi there

I can reproduce this error only on 1PC (unfavorable our productiv server). I tried to copie the eml IFilter (mimefilt.dll) on a test server to reproduce the problem, but no luck. Any Idea how to fix the problem? What dlls could be broken? This error oncuourred only by some e-mails. (and sometimes the pdf Filter had the same problem)

Greets

Mimefilt
A: 

Nothing like finding a posted question with no posted code / solution =( (no offense mbalkema). Can you show what you "blended", I'm coming across this article years later I realize =)

Thanks

scryptKiddy