Storage Helper for WinRT (Win8 Metro) in C#

Windows 8 Metro Storage Helper I’m currently coding a Windows 8 Metro app version of a Windows Phone 7.5 Mango app I previously made. There are quite a few differences in the code and one of the first stumbling blocks I hit was the lack of Isolated Storage in WinRT. There are some ways of making shared libraries compatible,  but I wanted to learn the new ways of doing things. One of the things I need to do is store POCOs to storage for caching and while having a quick search to see if someone…

Read More

Never to be caught out again...

Posting this here so as to reinforce my memory, so I never miss this again. LINQ errors that make no sense and the build error: “Cannot convert lambda expression to type ‘string’ because it is not a delegate type” = missing "using System.Linq;"…

Read More

Getting an Alexa Rank programmatically in C#

As part of a project I’m working on, I needed to lookup the Alexa Traffic Rank for a domain programmatically. I found the URL the toolbar uses and wrote function to parse the XML and return the value, which I thought I’d share in case it saves someone else 15 minutes of their life… private int GetAlexaRank(string domain) { var alexaRank = 0; try { var url = string.Format("http://data.alexa.com/data?cli=10&dat=snbamz&url={0}", domain); var doc = XDocument.Load(url);…

Read More

HttpWebRequest causes System.NotSupportedException' occurred in System.Windows.dll.

When using HttpWebRequest asynchronously in a Windows Phone 7 app, the console in Visual Studio was outputting: A first chance exception of type 'System.NotSupportedException' occurred in System.Windows.dll The fix was basically adding AllowReadStreamBuffering = true to the HttpWebRequest object. For example: var request = HttpWebRequest.CreateHttp(feed.Url); request.AllowReadStreamBuffering = true; This error didn’t cause my app to crash or any other problems other than the “first chanc…

Read More