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.

clip_image002

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

Advertisements

,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: