Visual Studio Achievements For VS2012

July 31 2012

The Visual Studio Achievements extension now supports VS2012. Read all about it here. And, there's a new achievement, BRAVE NEW WORLD, that you can get if you are running VS2012 on Windows 8. (Note: no one seems to have gotten the in joke about that achievement -- anyone?)

Background Transfer Download Sample For C# In Windows 8

September 27 2011
Was hitting buffer limits with the HttpClient even when I set the MaxResponseContentBufferSize property.  I even tried to get around the buffer problem by manually reading each byte out of the stream into my own byte array but still no luck. Then I found the Javascript sample for the Background Downloader: http://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61.
I realized I could use it from managed code too using the Windows.Networking.BackgroundTransfer namespace.  Check out the code -- much niftier than the HttpClient. The code is pretty straight forward: 
 
StorageFolder localFolder = KnownFolders.MusicLibrary; 
StorageFile sampleFile = await localFolder.CreateFileAsync("my.mp3", CreationCollisionOption.ReplaceExisting);
var downloader = new BackgroundDownloader() 
d = downloader.StartDownloadAsync(
new Uri("http://linkto.mp3", UriKind.Absolute), sampleFile);
d.Start();
What's nifty is that once you pass the handle to the IStorageFile, all the i/o as far as saving the file gets handled for you. And, you can queue them up, so your app can start downloading n number of files and the BackgroundDownloader handles it all for you.
There are Progress and Completed events wired up to the DownloadOperation although I can't quite figure out how to wire them up -- don't see any sample code and I can't seem to get the signature of the method handler right. It wants to be an AsyncActionProgressHandler with the BackgroundDownloadProgress type as its parameter, but when I create a method with that signature, the compiler isn't happy. I'm having the same problem with the Completed handler as well -- if anyone figures out how to do it in C# (its simple in Javascript, thanks to the promise object!) let me know!

.NET Metro Surface Area

September 22 2011
Pretty interesting slide in Krzysztof Cwalina's talk: http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-930C about the surface area for .NET metro apps. Note that the count on the .NET Metro APIs do not include the WinRT apis.
  .NET Metro .NET 4.5 Windows Phone
# assemblies 15+ 120 22
# namespaces 60 400 88
# types ~1k ~14k ~2k

Adding References To System Libraries In Windows 8

September 21 2011

I've been starting to hack on Windows 8 a bit, using C# and XAML and the .NET 4.5 Framework. Y'all will probably figure this out, but if you don't, here's the deal: when you go to add references to system libraries, none of your favorites (System.Web, System.Net, System.Security, PresentationCore, etc.) will show up.  You have to manually browse to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5 and walla, there they all are in their .NET glory. Party on.

Or not.  Didn’t realize this could get you in trouble when you go to submit.  Look here for the libraries available to you: http://msdn.microsoft.com/en-us/library/windows/apps/br230232%28v=VS.85%29.aspx 

Beware though: .NET in Windows 8 is not exactly .NET.  This reference page starts to explain http://msdn.microsoft.com/en-us/library/windows/apps/br230302(v=VS.85).aspx and this presentation http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-930C by the eminent Krzysztof Cwalina definitely helps. 

More coming...