Fix: Visual Studio Achievements and FxCop problem

Actually there is a problem with FxCop and Visual Studio Achievements (with Visual Studio Professional): the FxCop assemblies can’t be loaded.

Here is a workaround (note: you have to install FxCop 10.0 – not FxCop 1.36):

x86: You have to copy all files from "C:\Program Files\Microsoft Fxcop 10.0" to "C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop".

x64: You have to copy all files from "C:\Program Files (x86)\Microsoft Fxcop 10.0" to "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop".

Effective C# – summary

Actually I read a book about effective C# programming. It contains 50 tips.

Reading the first 5 items I decided to summarize most of the 50 tips and to advertise this book.

  1. Use properties instead of accessible data members
  2. Prefer readonly to const
  3. Prefer the is or as operator to casts
  4. Use conditional attributes instead of #if
  5. Always provide .ToString()
  6. Utilize using and try/finally for resource cleanup

Remove an assembly from the global assembly cache (GAC)

You can manage your global assemblies with the gacutil.exe which comes with Microsoft SDK. You can find this tool for instance in folder "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\".

This is an example about removing one assembly:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" /u Assembly.To.Uninstall

Howto access a protected method

Here is a small code snippet about howto access a protected method of a class:

Code Snippet
  1. public class OriginalClass
  2. {        
  3.     protected int OrginalProtectedMethod()
  4.     {
  5.         return 0;
  6.     }
  7. }
  8. public class MyDescClass : OriginalClass
  9. {
  10.     public int MyMethod() {
  11.         return OrginalProtectedMethod();
  12.     }
  13. }
  14.  
  15. // access the "protected method"
  16. var md = new MyDescClass();
  17. var result = md.MyMethod();