Once in a while it is good to review your code practices, and have a look if the coding approach you take in solving your problems is still “state of the art”. One important thing is performance: in a language like C# it is so easy to do great things in just few calls… it looks nice and clean, but results for example in the creation of loads of objects. good example: sometimes it is way better to just use a good old plain array like we used to do in the C days, instead of using the fance ArrayList collections.
I stumbled accross a great article by Jeff Varszegi on the performance topic that gives you some good ideas in a fast ten minute read: http://dotnet.sys-con.com/read/46342.htm.
I am currently working on an application using VS.NET 2005, and because all the TDD tools like unit testing and code coverage are available I started to use them.
When I started code coverage on my signed application I got the following exception:
Test method X threw exception: System.IO.FileLoadException: Could not load file or assembly 'Y, Version=184.108.40.206, Culture=neutral, PublicKeyToken=Z' or one of its dependencies. HRESULT: 0x8013141A Strong name validation failed. ---> System.Security.SecurityException: Exception from HRESULT: 0x8013141A Strong name validation failed at X.
Not so strange if you think about it. Assembly is signed, code coverage needs code instrumentation, means modifications of the assembly, resulting in incorrect assembly so the validation failed.
Solution is to resign the assembly after instrumentation.
If you open the localtestrun.testrunconfig file (or something similar) in your solution items (double-click it), you can enable resigning in the Code Coverage section. This solves the problem.
I found this solution through the following bug post on the Microsoft Product feedback Center: http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=5f59ce2a-65b1-487d-9f46-da8707179184