
HI,
I'm looking for a way to catch "Object reference not set to an instane of an object" error.
As I'm working with DocuRef files on my Dev machine I don't have access to the files that I did not store myself on my machine but were stored in Production database and when I try to get the Attachment Stream it gives me the error and my code ends.
I would like to know a way to proceed my code skipping just the method that gives me the error.
private void getDocuRefFile(RecId _docuRef)
{
DocuRef docuReflocal = docuRef::findRecId(_docuRef);
if(docuReflocal.RecId)
{
try
{
System.IO.Stream stream = DocumentManagement::getAttachmentStream(docuReflocal);
}
catch(Exception::Error)
{
}
}
} It'll be better if you can prevent the exception. Debug the code to see where the exception occurs and think about what you can do with it.
If it's not possible, use the following code to catch it:
System.NullReferenceException nullRefEx;
try
{
...
}
catch (nullRefEx)
{
}