I am trying to access a sharepoint list programmatically in a webpart, like this.
try
{
masterList = web.Lists[listId];
}
catch(Exception e)
{
RenderExceptionMessage(e.Message);
}
The RenderExceptionMessage() method is supposed to show a user-friendly error message inside the webpart.
But the problem is that I am not able to trap the Exception. Instead the webpart page redirects to an access denied page which shows an error message "You are currently signed in as: Domain\user"
Also, the message of the exception being caught reads "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack."
Any idea why this behaves this way?