WebClient not sending credentials? Here’s why!

TL;DR version here. This post applies to more than just GitHub, read the rest to see the behavior! I was playing with the GitHub API (more specifically generating a new OAuth token). So what you need to do, as per the documentation, is to post a certain JSON string to https://api.github.com/authorizations, with Basic Authentication. I’m […]

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 […]

Team Foundation 2010: Associate work item with changeset AFTER check in.

Today I was struggling associating a work item with a changeset after a check in. There is however no options for this in the UI. Or is there? Let’s check: Ok, so not through the changeset UI. Let’s check the command line. c:Program Files (x86)Microsoft Visual Studio 10.0VC>tf changeset /? TF – Team Foundation Version […]

Silverlight 4: Bug in TabControl.TabStripPlacement = Dock.Left and OnApplyTemplate

At work I ran into a bug with the Silverlight TabControl, more specifically when setting the TabStripPlacement to Dock.Left and hiding one of the TabItems in the parent’s OnApplyTemplate. The way to get to this bug is quite specific. For example, you can’t do it when you’re using a UserControl, since in that kind of […]