the application is blowing up on a
line inside of a try-catch block. Any
idea why this would be happening?
Shouldn't it just be failing silently?
Why would you think that an exception can't occur within a try/catch? The whole purpose of the try.catch block is to define how you intend exceptional situations to be handled. If there is no catch block corresponding to the type of exception thrown, the exception will propogate out until either some code catches it or until it is raised as unhandled.
It's, of course, possible to use Catch ex as Exception
as a block to catch all exceptions and then swallow them, but this is rarely a good idea.
As far as NullReferenceException
goes, you almost never want to catch them and handle them (almost never). They generally are an indication that there is a bug somewhere in the code where logic is not testing a reference for null
before accessing methods or properties on it. In fact, it's likely that the _MemoryStream
variable is itself the culprit - if it's null then invoking a call on it would raise that exact exception.