Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

SIL file corrupted


We had a crash in our application that we are investigating. When opening the sil file there is a lot black lines in the end like the file is corrupt. Is there any way that I can make sure that this doesn’t happen in the application? I handle unhandled exceptions on AppDomain and log what exception happens. But I can’t read it because the sil file is corrupted.

This the config: append=true, rotate=Daily, maxsize=0MB, maxparts=14, async.enabled=true, level=Debug


Hello Michael,

Thanks for your posting. Was the application terminated unexpectedly (e.g. by an unhandled exception in the main thread)? If so (and if SmartInspect was currently active in a different thread), SmartInspect may have been in the middle of writing a log packet and this may lead to writing an incomplete log packet.

We make sure to write packets in as few Write calls as possible and also don’t use any I/O buffering by default, so there’s little we can do to change this behavior if your application crashes and is terminated.



Is there anyway to know when SmartInspect has finished writing to the file?


If you don’t use asynchronous logging and no buffering options, SmartInspect has fully finished writing to the log file after the log statement has returned (e.g. LogMessage etc.) (it writes the log entry with as few Write calls as possible and then calls Stream.Flush). Using asynchronous logging or I/O buffering will change this behavior as logging will then occur in a separate thread or use an I/O buffer to optimize I/O performance (both options are disabled by default).

That said, regardless of the options you are using, if your application is terminated unexpectedly, this may happen in the middle of a Write operation and this may lead to the behavior you’ve seen.