Tuesday, March 01, 2011

Getting Past SharePoint Exceptions with “Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.”

Problem: You’re seeing odd SharePoint exception behavior throwing vague “Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack” messages as a general exception.

Issue: You may likely be seeing an Access Denied issue; however, SharePoint “helpfully” adds custom handling for that and bypasses general exception handling for you.

Solution: Turn off the CatchAccessDeniedException property, then reset it after you’re done with your code. See the example in MSDN documentation for specifics.

(Hat tip: Paul-Jan on StackOverflow)

No comments:

Post a Comment