Posts Tagged Exception

Ever get this exception in a C# program?


This post is a bit of a tip on how to solve the following Exception. It does rely on the Code Analysis feature new in Visual Studio 2010.


Well here are a couple of tips to determine just where in the format string the error is:

  1. Rebuild the project with Code Analysis (menu Project -> <<Project name>> Properties).
    • clip_image004 is the option which need to be switched on.
    • Rebuild
    • Check the Errors Window: clip_image006
    • Which is all well and good but, where on earth is 3208 in the string?
  2. Debug the project.
    • Break on where the string is being used (not necessary but helps me keep my mind on what I’m trying to do)
    • Quick watch the string variable.
    • The Do a substring of the string to show the segment which has the error in it.
    •  clip_image008
  3. Correct the error (need “{{“and “}}” in the format string for the single braces in the input string.

Technorati Tags: ,,,,,,,,,,,,,,,,,

Windows Live Tags: exception,Code,Analysis,Visual,Studio,error,Rebuild,menu,Project,Properties,option,Check,Errors,Debug,Break,Quick,segment,Correct

WordPress Tags: exception,Code,Analysis,Visual,Studio,error,Rebuild,menu,Project,Properties,option,Check,Errors,Debug,Break,Quick,segment,Correct


Leave a comment

%d bloggers like this: