Unless you have a VERY good reason, rethrow your exception.

I see it a lot, people write a function, they catch a possible exception and throw one of their own OmgSomethingHorribleHappenedException(); Check this simplefied example: private static void Main() { try { var result = (new Api()).Find(“foo”); Process(result); } catch (Exception e) { Console.WriteLine(e.Message + Environment.NewLine + e.StackTrace); Console.Read(); } } And the Api.Find(string toFind) […]

Deserializing xml: Data at the root level is invalid. Line 1, position 1

A couple of days ago a colleague of mine encountered a problem where he had some objects that define a configuration needed to be stored in the database. He would serialize the data with the following code: public static class XmlSerializerHelper { public static string SerializeXml<TObject>(this TObject objectToSerialize) { using (var memoryStream = new MemoryStream()) […]

Check if your LinkedIn password appears in the leaked file.

Get the file from the internet. Change the line that points to the file. Run the app, type your password and be happy or sad. using System; using System.IO; using System.IO.MemoryMappedFiles; using System.Security.Cryptography; using System.Text; namespace LinkedInFileSearcher { internal static class Program { private const string PathToLinkedInFile = @”c:\combo_not.txt”; private static void Main() { ConsoleKeyInfo […]

Get your facts right.

I just read this article: http://www.simple-talk.com/dotnet/.net-framework/10-reasons-why-visual-basic-is-better-than-c/ . And I’m pissed. Why? Allow me to elaborate First of all, because on the top right there is “a service from redgate”. You’d expect to get their facts right. And that’s the main issue with this article. There will always be fights among developers about which language is […]

Your project dependencies matter (when using NuGet)

At work we had the following issue, we had a Silverlight project consuming some NuGet package, this project was being exposed in a Web application. In order to keep our solution clean – we didn’t want an ‘assemblies’ folder – we used NuGet package restore. We did it like the book said, don’t check in […]