Thursday 28 August 2008

This element is not currently associated with any context

When debugging unit for a WCF client in Visual studio 2008 you often come across following error message. "A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll

Additional information: This element is not currently associated with any context"

If the test is executed in non debug mode it works fine, without any glitches. This is because some of the exception which otherwise handled by WCF library is not handled in debug mode.Fix is simple. Open the Exception dialog box from Debug menu and deselect the Common Language Runtime Exception check box. Shown in red in following diagram. This simply tells Visual Studio not to break in system exception.
This happens because WCF throws and catches exception for it's normal application flow. Apparently there is no fix to it. See the post in MSDN(http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1025211&SiteID=1).

5 comments:

  1. Recommendation of AronW is move useful. I want to see exception's source when I have any trouble.

    ReplyDelete
  2. The approach is right. But you don't have to disable all exceptions, just the one. See here: http://discoveringdontnet.alexeyev.org/2009/06/this-element-is-not-currently.html

    ReplyDelete
  3. You don't have to disable all exceptions. Just one causing you trouble: http://discoveringdotnet.alexeyev.org/2009/06/this-element-is-not-currently.html

    ReplyDelete
  4. I had a weird issue where I got this error after I changed the "just my code" option in the debugger settings. There were no boxes checked in the exception window so this should not have happened. It was resolved only when I clicked the "reset all" button.

    It looks like yet another crazy quirk in the IDE. I use Visual Studio 2008 with all the relevant hot fixes applied and yet the the dragging and placement of frames within the main window is still broken. The hotfixes only stopped it from crashing. I really hope they fix all this is the 2010 version.

    ReplyDelete
  5. The best solution (in my opinion) is to Turn On "Just My Code" flag, (under (Tools->Options->Debugging->General), ensuring that only exceptions from my code will stop the execution.

    ReplyDelete