Error in Guidance Automation Toolkit VS 2008 installation

In some of project in one of my C# solutions, I have run while clicking Calculate Code Metrics into an error message: An error occurred while calculating code metrics, while the build was successful and runtime behavior was allright.

Error message

What to do now ?. I have noticed that in Output window, there are some error messages also:

C:\…\Microsoft.CSharp.targets : warning MSB3042: A namespace or class definition was found within a conditional compilation directive in the file "XXX.cs". This may lead to an incorrect choice for the manifest resource name for resource "XXX.resx".

As the message says, I have found that construction that is preventing correct Code Metrics Calculation is ussage of conditional symbols before class (or namespaces).
Wrong code sample:

namespace TestingNamespace
// .. Working Code here

The next steps are now to remove conditional symbols and use some logic to do the same logic instead. After replacing all the symbols reported in error messages, everything is fine and Metrics are calculated correctly 🙂

I have found during my attempts to compute metrics, these important tips:
1. When Calculation of Metrics finishes with error message, it is good to do Code Analysis before. This will usually show you the exact place where the problem lies.
2. When you have strongly named assembly (signed with a key), it cannot be linked to another (not signed one) in Code Analysis and in Metrics Calculation.


Leave a Reply

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

You are commenting using your 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