<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>IBlog&amp;lt;Johan&amp;gt;</title><link>http://weblogs.asp.net/jdanforth/default.aspx</link><description>This and that in a developer's life in general</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Center Aligning a Table with CSS</title><link>http://weblogs.asp.net/jdanforth/archive/2013/02/01/center-aligning-a-table-with-css.aspx</link><pubDate>Fri, 01 Feb 2013 09:14:40 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9823901</guid><dc:creator>jdanforth</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;So you want to center align a table, try &lt;em&gt;text-align: center&lt;/em&gt; and it doesn’t work…. I have to look this up every time, so here goes:&lt;/p&gt; &lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;       &lt;p&gt;&amp;lt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;font color="#800000" size="2" face="Consolas"&gt;&lt;font color="#800000" size="2" face="Consolas"&gt;&lt;font color="#800000" size="2" face="Consolas"&gt;table&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;style&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;=&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;margin-left&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt;: &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;auto&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt;; &lt;/font&gt;&lt;/font&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;margin-right&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt;: &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;auto&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&amp;quot;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;This is because &lt;em&gt;text-align&lt;/em&gt; applies to inline content, not to a block-level element like a table and this article describes it in detail:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a title="http://www.granneman.com/webdev/coding/css/centertables/" href="http://www.granneman.com/webdev/coding/css/centertables/"&gt;http://www.granneman.com/webdev/coding/css/centertables/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Thanks Scott Granneman for the detailed article.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9823901" width="1" height="1"&gt;</description></item><item><title>Binding MediaElement to a ViewModel in a Windows 8 Store App</title><link>http://weblogs.asp.net/jdanforth/archive/2012/12/14/binding-mediaelement-to-a-viewmodel-in-a-windows-8-store-app.aspx</link><pubDate>Fri, 14 Dec 2012 14:07:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9583091</guid><dc:creator>jdanforth</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;If you want to play a video from your video-library in a MediaElement control of a &lt;strike&gt;Metro&lt;/strike&gt; Windows Store App and tried to bind the Url of the video file as a source to the MediaElement control like this, you may have noticed it’s not working as well for you:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21); font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;MediaElement&lt;/span&gt;&lt;span style="background: white; color: red; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt; Source&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;="{&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21); font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Binding&lt;/span&gt;&lt;span style="background: white; color: red; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt; Url&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;}" /&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;        &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;I have no idea why it’s not working, but I managed to get it going using&amp;nbsp; ContentControl instead:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 10pt;"&gt;&lt;span style="background: white; color: blue; line-height: 115%; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21); line-height: 115%; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;ContentControl&lt;/span&gt;&lt;span style="background: white; color: red; line-height: 115%; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt; Content&lt;/span&gt;&lt;span style="background: white; color: blue; line-height: 115%; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;="{&lt;/span&gt;&lt;span style="background: white; color: rgb(163, 21, 21); line-height: 115%; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Binding&lt;/span&gt;&lt;span style="background: white; color: red; line-height: 115%; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt; Video&lt;/span&gt;&lt;span style="background: white; color: blue; line-height: 115%; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;}" /&amp;gt;&lt;/span&gt;     &lt;/p&gt;  &lt;p&gt;The code behind for this is:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;protected&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;override&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;void&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; OnNavigatedTo(&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;NavigationEventArgs&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; e)        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;{        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_viewModel = &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;new&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;VideoViewModel&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;(&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(163, 21, 21); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;"video.mp4"&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;);        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;DataContext = _viewModel;        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;}        &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;And the VideoViewModel looks like this:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;public&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;class&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;VideoViewModel&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;{        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;private&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;readonly&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;MediaElement&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; _video;        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;private&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;readonly&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;string&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; _filename;        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;     &lt;/span&gt;&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;     &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;public&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; VideoViewModel(&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;string&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; filename)        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_filename = filename;         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_video = &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;new&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;MediaElement&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; { AutoPlay = &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;true&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; };        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: green; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;//don't load the stream until the control is ready&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_video.Loaded += VideoLoaded;         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;     &lt;/span&gt;&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;     &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;public&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;MediaElement&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; Video        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;get&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; { &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;return&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; _video; }        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;     &lt;/span&gt;&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;     &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;private&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;async&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;void&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; VideoLoaded(&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;object&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; sender, &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;RoutedEventArgs&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; e)        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;var&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; file = &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;await&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;KnownFolders&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;.VideosLibrary.GetFileAsync(_filename);        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;var&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; stream = &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;await&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; file.OpenAsync(&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;FileAccessMode&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;.Read);        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_video.SetSource(stream, file.FileType);         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;}        &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="background: white; color: black; line-height: 115%; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: sv; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: en-us; mso-bidi-language: ar-sa;"&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;I had to wait for the MediaElement.Loaded event until I could load and set the video stream. &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9583091" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/c_2300_/default.aspx">c#</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Windows+8/default.aspx">Windows 8</category></item><item><title>File Activation in Windows RT</title><link>http://weblogs.asp.net/jdanforth/archive/2012/11/23/file-activation-in-windows-rt.aspx</link><pubDate>Fri, 23 Nov 2012 10:57:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9446139</guid><dc:creator>jdanforth</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;The code sample for file activation on MSDN is lacking some code &lt;img class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://weblogs.asp.net/blogs/jdanforth/wlEmoticon-winkingsmile_66327A73.png" mce_src="http://weblogs.asp.net/blogs/jdanforth/wlEmoticon-winkingsmile_66327A73.png"&gt; so a simple way to pass the file clicked to your MainPage could be:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;protected&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;override&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;void&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; OnFileActivated(&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;FileActivatedEventArgs&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; args)        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;{        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;var&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; page = &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;new&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;Frame&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;();        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;page.Navigate(&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;typeof&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;(&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;MainPage&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;));        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;Window&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;.Current.Content = page;        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;     &lt;/span&gt;&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;     &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;var&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; p = page.Content &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;as&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;MainPage&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;;        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;if&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; (p != &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;null&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;) p.FileEvent = args;        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Window&lt;/span&gt;&lt;span style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Current.Activate();        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;}        &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;And in MainPage:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;public&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; MainPage()        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;{        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;InitializeComponent();         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Loaded += MainPageLoaded;         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;}        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;void&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; MainPageLoaded(&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;object&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; sender, &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: rgb(43, 145, 175); font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;RoutedEventArgs&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; e)        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;{        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;if&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; (FileEvent != &lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: blue; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;null&lt;/span&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt; &amp;amp;&amp;amp; FileEvent.Files.Count &amp;gt; 0)        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//… do something with file         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span lang="EN-GB" style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white; mso-ansi-language: en-gb;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}         &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: consolas; font-size: 9.5pt; mso-highlight: white;"&gt;}        &lt;/span&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9446139" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/c_2300_/default.aspx">c#</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/window/default.aspx">window</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/c/default.aspx">c</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/winr/default.aspx">winr</category></item><item><title>Read All Text from Textfile with Encoding in Windows RT</title><link>http://weblogs.asp.net/jdanforth/archive/2012/11/21/read-all-text-from-textfile-with-encoding-in-windows-rt.aspx</link><pubDate>Wed, 21 Nov 2012 14:53:52 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9432533</guid><dc:creator>jdanforth</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;A simple extension for reading all text from a text file in WinRT with a specific encoding, made as an extension to StorageFile:&lt;/p&gt;  &lt;p&gt;&lt;font face="Consolas"&gt;public static class StorageFileExtensions     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; async public static Task&amp;lt;string&amp;gt; ReadAllTextAsync(this StorageFile storageFile)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var buffer = await FileIO.ReadBufferAsync(storageFile);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var fileData = buffer.ToArray();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var encoding = Encoding.GetEncoding(&amp;quot;Windows-1252&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var text = encoding.GetString(fileData, 0, fileData.Length);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return text;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9432533" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/c_2300_/default.aspx">c#</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Windows+8/default.aspx">Windows 8</category></item><item><title>Sideloading and Testing Windows 8 Store Apps on Other Machines</title><link>http://weblogs.asp.net/jdanforth/archive/2012/11/20/sideloading-and-testing-windows-8-store-apps-on-other-machines.aspx</link><pubDate>Tue, 20 Nov 2012 13:32:24 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9424880</guid><dc:creator>jdanforth</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;This is a good, short article how to create a store app package and test on another machine, see &lt;a title="http://blog.aggregatedintelligence.com/2012/11/how-to-sideload-windows-8-store-apps.html" href="http://blog.aggregatedintelligence.com/2012/11/how-to-sideload-windows-8-store-apps.html"&gt;http://blog.aggregatedintelligence.com/2012/11/how-to-sideload-windows-8-store-apps.html&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9424880" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Windows+8/default.aspx">Windows 8</category></item><item><title>How to do Custom Event Logging and Trace Writing in Azure</title><link>http://weblogs.asp.net/jdanforth/archive/2012/02/24/how-to-do-custom-event-logging-and-trace-writing-in-azure.aspx</link><pubDate>Fri, 24 Feb 2012 14:56:10 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8311514</guid><dc:creator>jdanforth</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;We’re about to begin our first “real” Azure project and I needed to wrap my head around event logging and trace writing in the cloud. Any proper application running in any cloud needs this sooner or later.&lt;/p&gt;  &lt;p&gt;I quickly noticed that the information around Azure diagnostics was all over the place, and some things seems to have been changed in newer versions of the Azure SDK. So, something I thought was going to take me just a few minutes to figure out took about a day, but I think I got it sorted in the end and here’s what I did to get simple event logging and trace writing to work for our web role. &lt;/p&gt;  &lt;p&gt;First thing I had to understand was how data for all kinds of diagnostics is handled and stored in Azure. You need to define which kinds of diagnostics data you want to capture, and you need to define where Azure should transfer the data captured so that you can download them or look at then with various tools. You also need to define how often these values should be transferred. I’ll get back to that a bit later.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Create a Custom Event Source&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;First thing I wanted to have was a custom event source to write to for warnings and errors. To do this I created a simple cmd-file which I placed inside the web role project and uploaded with the packed deployment. Now when the web role is deployed, you define startup task which runs in elevated mode (to be able to create the event source) and points to this cmd-file. So, create a file inside your project’s root called &lt;strong&gt;CreateEventSource.cmd&lt;/strong&gt; and put this inside it:&lt;/p&gt;  &lt;pre style="font-family: consolas; background: white; color: black; font-size: 13px"&gt;&lt;strong&gt;EventCreate /L Application /T Information /ID 900 /SO &amp;quot;MySource&amp;quot; /D &amp;quot;my custom source&amp;quot;&lt;/strong&gt;&amp;#160;&lt;/pre&gt;

&lt;pre style="font-family: consolas; background: white; color: black; font-size: 13px"&gt;&lt;font face="Verdana"&gt;&lt;strong&gt;NOTE! &lt;/strong&gt;Make sure the cmd-file property for “copy to output directory” is set to “copy always” or “copy if newer”.&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="font-family: consolas; background: white; color: black; font-size: 13px"&gt;&lt;font face="Verdana"&gt;Then open up your service definition file, &lt;strong&gt;ServiceDefinition.csdef&lt;/strong&gt;, and add a startup task to it:&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ServiceDefinition&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MyWeb&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;WebRole&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MyWebRole&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;vmsize&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ExtraSmall&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;strong&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Startup&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Task&lt;/span&gt; &lt;span class="attr"&gt;commandLine&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;CreateEventSource.cmd&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;executionContext&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;elevated&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;taskType&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;simple&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Startup&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;/strong&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Sites&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
… and so on…
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ServiceDefinition&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;So now when your application is deployed the cmd-file should be executed with elevated permission and create the event log source you specified. &lt;strong&gt;EventCreate&lt;/strong&gt; is a tool which is available on the Azure server so it’s nothing you need to worry about. Same thing should work well on your local dev machine too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Storage Location for Diagnostics Data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You need a place for the diagnostics data to be transferred to. This is number of Azure Storage tables so you need to create an Azure Storage Account where Azure can create these specific tables and transfer the captured data. So you basically go to the Azure Management Portal and create a new Storage Account and copy the access key. Then paste the storage account name and key into the Service Configuration:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_766969F9.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_231223D3.png" width="642" height="216" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now when Azure starts to transfer data from event log and trace writes, they will be written to these two tables; WADLogsTable and WADWindowsEventLogsTable:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_33AA1EC1.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_6BE895D9.png" width="242" height="114" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you capture performance counters and such, these will be written to other tables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Diagnostics Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next thing to do is to configure which diagnostics to capture for your application. This is done in the &lt;strong&gt;OnStart()&lt;/strong&gt; method of your &lt;strong&gt;WebRole.cs&lt;/strong&gt; file. What I wanted to test initially was event logging to my custom source and also some trace writings for information, warning and errors. I also specified how frequently I wanted these diagnostics to be written to the storage tables:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; OnStart()
{
    var diag = DiagnosticMonitor.GetDefaultInitialConfiguration();
            
    diag.Logs.ScheduledTransferLogLevelFilter = LogLevel.Information;
    diag.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(30);

    diag.WindowsEventLog.DataSources.Add(&lt;span class="str"&gt;&amp;quot;Application!*[System[Provider[@Name='MySource']]]&amp;quot;&lt;/span&gt;); 
    diag.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromSeconds(30);

    DiagnosticMonitor.Start(&lt;span class="str"&gt;&amp;quot;Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString&amp;quot;&lt;/span&gt;, diag); 

    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnStart();
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Note a few things about this code – The transfer schedule is set to 30 seconds and you may want to set this one a bit higher and also look at the buffer quotas. The sample code is also only capturing and transferring event logs from the “Application” logs, and I’ve added an xpath expression to only transfer logs from the “MySource” event source we specified in the cmd-file earlier. You may want to grab all application events as well as all system logs too, in that case:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;diag.WindowsEventLog.DataSources.Add(&lt;span class="str"&gt;&amp;quot;System!*&amp;quot;&lt;/span&gt;);
diag.WindowsEventLog.DataSources.Add(&lt;span class="str"&gt;&amp;quot;Application!*&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Writing to Event and Trace Logs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The simplest thing is then to add some code to write to the event log and trace logs in your code, for example:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Trace.TraceError(&lt;span class="str"&gt;&amp;quot;Invalid login&amp;quot;&lt;/span&gt;);
EventLog.WriteEntry(&lt;span class="str"&gt;&amp;quot;MySource&amp;quot;&lt;/span&gt;,&lt;span class="str"&gt;&amp;quot;Invalid login&amp;quot;&lt;/span&gt;,EventLogEntryType.Error);&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Looking at the Data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To actually see what’s been written to these tables, you need to either download the data from the storage tables via APIs, use the server explorer or some tool, like the one from Cerebrata – “Azure Diagnostics Manager” – which seems to do the job pretty well. As far as I know, there is no proper tool available from Microsoft. Be that as it may. &lt;/p&gt;

&lt;p&gt;Please, feel free to write comments below and add tips and tricks about handling diagnostics in your Azure application. I’d like to know more about the Transfer Period and Buffer Quotas and how they may affect the application and maybe also the billing… I’m sure there are loads to learn about this &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="http://weblogs.asp.net/blogs/jdanforth/wlEmoticon-smile_31F952ED.png" /&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8311514" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Azure/default.aspx">Azure</category></item><item><title>How to Force Comments When Doing Check-In in TFS</title><link>http://weblogs.asp.net/jdanforth/archive/2012/02/08/how-to-force-comments-when-doing-check-in-in-tfs.aspx</link><pubDate>Wed, 08 Feb 2012 09:35:52 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8288654</guid><dc:creator>jdanforth</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I was looking for a policy like this, and found this blog article by Claus Konrad:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://blog.clauskonrad.net/2010/08/tfs-2010-how-to-force-comments-when.html" href="http://blog.clauskonrad.net/2010/08/tfs-2010-how-to-force-comments-when.html"&gt;http://blog.clauskonrad.net/2010/08/tfs-2010-how-to-force-comments-when.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, unfortunately everyone in the project has to have the TFS Power Tools installed to make this work.&lt;/p&gt;  &lt;p&gt;The power tools can be downloaded from the Visual Studio Gallery, this is a direct link to it: &lt;/p&gt;  &lt;p&gt;&lt;a title="http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f?SRC=VSIDE" href="http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f?SRC=VSIDE"&gt;http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f?SRC=VSIDE&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Whish this was in the box from start.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8288654" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/TFS/default.aspx">TFS</category></item><item><title>MSTest and Calling Exe with Sample Data Files</title><link>http://weblogs.asp.net/jdanforth/archive/2012/02/07/mstest-and-calling-exe-with-sample-data-files.aspx</link><pubDate>Tue, 07 Feb 2012 08:52:59 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8286612</guid><dc:creator>jdanforth</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;For various reasons I’m using MSTest for my unit tests and I have this console app which generates a PDF file from an XML file that needed some tests.&lt;/p&gt;  &lt;p&gt;So, when moving the unit tests over to a TFS build server, having hard coded paths to test data files is not a good idea. The recommended way of doing it is to use the DeploymentItem attribute.&lt;/p&gt;  &lt;p&gt;Also, when calling an exe-file which does Environment.Exit() and catching the exit code from the unit test is pretty straight forward by using Process.Start() and checking the ExitCode property.&lt;/p&gt;  &lt;p&gt;A small sample:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;[TestMethod]
[DeploymentItem(&lt;span class="str"&gt;@&amp;quot;TestData\arbetsorder.xml&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;TestData&amp;quot;&lt;/span&gt;)]
[DeploymentItem(&lt;span class="str"&gt;@&amp;quot;TestData\arbetsorderReport.rdlc&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;TestData&amp;quot;&lt;/span&gt;)]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; GeneratorShouldReturnWithExitCode0()
{
    Process proc;
    &lt;span class="kwrd"&gt;try&lt;/span&gt;
    {
        proc = Process.Start(&lt;span class="str"&gt;&amp;quot;PdfGenerator.exe&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;\&amp;quot;&amp;quot;&lt;/span&gt; + Directory.GetCurrentDirectory() + &lt;span class="str"&gt;&amp;quot;/TestData/arbetsorderReport.rdlc\&amp;quot; \&amp;quot;&amp;quot;&lt;/span&gt; +
            Directory.GetCurrentDirectory() + &lt;span class="str"&gt;&amp;quot;/arbetsorder.pdf\&amp;quot; \&amp;quot;&amp;quot;&lt;/span&gt; + Directory.GetCurrentDirectory() + &lt;span class="str"&gt;&amp;quot;/TestData/arbetsorder.xml\&amp;quot;&amp;quot;&lt;/span&gt;);
    }
    &lt;span class="kwrd"&gt;catch&lt;/span&gt; (System.ComponentModel.Win32Exception ex)
    {
        proc = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
        Assert.Fail(ex.Message);
    }

    Assert.IsNotNull(proc);
    proc.WaitForExit(10000);
    Assert.IsTrue(proc.HasExited);
    Assert.AreEqual(0, proc.ExitCode, &lt;span class="str"&gt;&amp;quot;Expected 0, got &amp;quot;&lt;/span&gt; + proc.ExitCode);
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;But, there’s a small caveat to get the DeploymentItem argument working properly! First you have to open up the test settings of your .testsettings file, select the Deployment settings and make sure the “Enable deployment” checkbox is checked:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_69D77233.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_369B38CA.png" width="644" height="475" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s all you need to do. And &lt;em&gt;note that you may actually have to exit and restart Visual Studio to make it work&lt;/em&gt;. I never got the files deployed until I did that restart.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8286612" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Unit+Testing/default.aspx">Unit Testing</category></item><item><title>Command Handling the Nancy Way</title><link>http://weblogs.asp.net/jdanforth/archive/2011/09/08/command-handling-the-nancy-way.aspx</link><pubDate>Thu, 08 Sep 2011 13:50:55 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7945819</guid><dc:creator>jdanforth</dc:creator><slash:comments>5</slash:comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/minibuss_small_thumb1_thumb_thumb_353836CC.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="minibuss_small_thumb1_thumb_thumb" border="0" alt="minibuss_small_thumb1_thumb_thumb" src="http://weblogs.asp.net/blogs/jdanforth/minibuss_small_thumb1_thumb_thumb_thumb_5FA467E9.png" width="36" height="28" /&gt;&lt;/a&gt; MiniBuss is a micro service bus framework over msmq which consists of less than 400 lines of code, sitting inside one single source file. The project is hosted over at &lt;a href="http://minibuss.codeplex.com"&gt;http://minibuss.codeplex.com&lt;/a&gt; and the source code is maintained at &lt;a title="https://github.com/johandanforth/MiniBuss" href="https://github.com/johandanforth/MiniBuss"&gt;https://github.com/johandanforth/MiniBuss&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I’ve been a fan of &lt;a href="https://github.com/NancyFx/Nancy" target="_blank"&gt;the Sinatra inspired web framework called Nancy&lt;/a&gt;, especially the neat way of setting up handlers for routes. The simplest sample on their site is this:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Module : NancyModule
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; Module()
    {
        Get[&lt;span class="str"&gt;&amp;quot;/greet/{name}&amp;quot;&lt;/span&gt;] = x =&amp;gt; {
            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;.Concat(&lt;span class="str"&gt;&amp;quot;Hello &amp;quot;&lt;/span&gt;, x.name);
        };
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;So, I shamelessly dug into the Nancy code and borrowed some 20-30 lines of code and came up with something like this for registering handlers for certain incoming commands on the minibus, what do you think?&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CommandHandler : MessageHandler
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; CommandHandler()
    {
        WhenReceiving[&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(SampleMessage1)] = x =&amp;gt;
        {
            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;sample 1 message: &amp;quot;&lt;/span&gt; + x.Text);
        };

        WhenReceiving[&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(SampleMessage2)] = x =&amp;gt;
        {
            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;sample 2 message: &amp;quot;&lt;/span&gt; + x.Text);
        };
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;It’s a bit more code but it helps/enforces you to move the handlers off to a certain module. Thoughts?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7945819" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Open+Source/default.aspx">Open Source</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Service+Bus/default.aspx">Service Bus</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/MiniBuss/default.aspx">MiniBuss</category></item><item><title>More MiniBuss Updates</title><link>http://weblogs.asp.net/jdanforth/archive/2011/09/02/more-minibuss-updates.aspx</link><pubDate>Fri, 02 Sep 2011 20:23:23 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7937324</guid><dc:creator>jdanforth</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/minibuss_small_thumb1_thumb_51B22E2D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="minibuss_small_thumb1_thumb" border="0" alt="minibuss_small_thumb1_thumb" src="http://weblogs.asp.net/blogs/jdanforth/minibuss_small_thumb1_thumb_thumb_02D168CE.png" width="36" height="28" /&gt;&lt;/a&gt; MiniBuss is a micro service bus framework over msmq which consists of less than 400 lines of code, sitting inside one single source file. The project is hosted over at &lt;a href="http://minibuss.codeplex.com"&gt;http://minibuss.codeplex.com&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Thanks to @CodingInsomnia for testing out the MiniBuss stuff a bit more than I did &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://weblogs.asp.net/blogs/jdanforth/wlEmoticon-winkingsmile_61DDF626.png" /&gt; For the samples, and for my initial testing code, I used a shared assembly with messages (events and commands), which shouldn’t be necessary. So I made a few simple changes and now you can choose to either share messages in an assembly between your sender/receiver and publisher/subscribers OR you can declare local message classes &lt;strong&gt;as long as those classes use the same class name and properties&lt;/strong&gt; it should work.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;NuGet package has been updated&lt;/strong&gt;, and the new code is in package version 1.0.2.0.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7937324" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Open+Source/default.aspx">Open Source</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Codeplex/default.aspx">Codeplex</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Service+Bus/default.aspx">Service Bus</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/CQRS/default.aspx">CQRS</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/msmq/default.aspx">msmq</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/MiniBuss/default.aspx">MiniBuss</category></item><item><title>MiniBuss Updates</title><link>http://weblogs.asp.net/jdanforth/archive/2011/09/01/minibuss-updates.aspx</link><pubDate>Thu, 01 Sep 2011 09:35:31 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7935265</guid><dc:creator>jdanforth</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/minibuss_small_thumb1_377C04CA.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="minibuss_small_thumb1" border="0" alt="minibuss_small_thumb1" src="http://weblogs.asp.net/blogs/jdanforth/minibuss_small_thumb1_thumb_61E835E7.png" width="36" height="28" /&gt;&lt;/a&gt; I made a small update to &lt;a href="http://minibuss.codeplex.com/" target="_blank"&gt;MiniBuss&lt;/a&gt;, the micro service bus framework. The messages you send, Commands and Events, are &lt;strong&gt;no longer dependent on IMessage&lt;/strong&gt;. The messages sent on the bus can now be any .NET class which can be safely serialized.&lt;/p&gt;  &lt;p&gt;The MiniBuss package on NuGet has been updated (version 1.1.0.1).&lt;/p&gt;  &lt;p&gt;I’m looking for testers, reviewers and co-authors. Areas I want to look more at are multithreading/concurrency and the reply-feature (especially being able to reply to current message in multithreaded scenarios. &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7935265" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Open+Source/default.aspx">Open Source</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Codeplex/default.aspx">Codeplex</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Service+Bus/default.aspx">Service Bus</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/msmq/default.aspx">msmq</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/MiniBuss/default.aspx">MiniBuss</category></item><item><title>MiniBuss on Codeplex</title><link>http://weblogs.asp.net/jdanforth/archive/2011/08/30/minibuss-on-codeplex.aspx</link><pubDate>Tue, 30 Aug 2011 11:48:17 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7932243</guid><dc:creator>jdanforth</dc:creator><slash:comments>7</slash:comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/minibuss_small_3A94372C.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="minibuss_small" border="0" alt="minibuss_small" src="http://weblogs.asp.net/blogs/jdanforth/minibuss_small_thumb_478E173D.png" width="36" height="28" /&gt;&lt;/a&gt; The micro service bus framework for msmq called MiniBuss is now open source on Codeplex at &lt;a href="http://minibuss.codeplex.com"&gt;http://minibuss.codeplex.com&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;There is also now a NuGet package available for easy install into projects: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_06EBCACE.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_25C23EAC.png" width="644" height="364" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you’re interested in co-op on this project, please contact me via Codeplex! I’m looking for devs and tester who knows their c#, msmq and concurrency.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7932243" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/c_2300_/default.aspx">c#</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Open+Source/default.aspx">Open Source</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Codeplex/default.aspx">Codeplex</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Service+Bus/default.aspx">Service Bus</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/msmq/default.aspx">msmq</category></item><item><title>A One File .NET Micro Service Bus for MSMQ?</title><link>http://weblogs.asp.net/jdanforth/archive/2011/08/19/a-one-file-net-micro-service-bus-for-msmq.aspx</link><pubDate>Fri, 19 Aug 2011 11:15:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7917012</guid><dc:creator>jdanforth</dc:creator><slash:comments>11</slash:comments><description>&lt;p&gt;This last year our company has invested quite some time in looking at CQRS, which led to looking at great looking service-buses like &lt;a href="http://www.nservicebus.com/" target="_blank"&gt;nServiceBus&lt;/a&gt;, &lt;a href="http://hibernatingrhinos.com/open-source/rhino-service-bus" target="_blank"&gt;Rhino Service Bus&lt;/a&gt; and &lt;a href="http://masstransit-project.com/" target="_blank"&gt;Mass Transit&lt;/a&gt;, which led me to do some bus-coding on my own, mostly for fun and for learning MSMQ.&lt;/p&gt;  &lt;p&gt;Inspired by the service buses mentioned above, the result became a bare-bones-one-file “micro service bus” that I call MiniBuss which sits on top of MSMQ. The file itself is only some 400 lines of code and supports send, receive, reply, publish and subscribe/unsubscribe.&lt;/p&gt;  &lt;p&gt;Setting up a &lt;strong&gt;sender&lt;/strong&gt; may look something like this:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7c91c1dd-8041-425f-a9d5-74f4974fb427" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; bus = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; MiniBuss.&lt;span style="color:#2b91af"&gt;ServiceBus&lt;/span&gt;();&lt;br&gt; &lt;br&gt; bus.RegisterMessageEndpoint&amp;lt;&lt;span style="color:#2b91af"&gt;HelloCommand&lt;/span&gt;&amp;gt;(&lt;span style="color:#a31515"&gt;&amp;quot;minibuss_receiver1@johan-dell-ssd&amp;quot;&lt;/span&gt;);&lt;br&gt; &lt;br&gt; bus.Start();&lt;br&gt; &lt;br&gt; bus.Send(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HelloCommand&lt;/span&gt; { Guid = &lt;span style="color:#2b91af"&gt;Guid&lt;/span&gt;.NewGuid(), Message = &lt;span style="color:#a31515"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt; });&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Create the bus, register a message and tell it where messages of this type should go, start the bus and send the message.&lt;/p&gt;  &lt;p&gt;Setting up a &lt;strong&gt;receiver&lt;/strong&gt; may look something like this:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a8260128-689a-43e0-8fea-0ed31dbbd249" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; bus = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ServiceBus&lt;/span&gt; { LocalEndpoint = &lt;span style="color:#a31515"&gt;&amp;quot;minibuss_receiver1&amp;quot;&lt;/span&gt; };&lt;br&gt; &lt;br&gt; bus.RegisterMessageHandler&amp;lt;&lt;span style="color:#2b91af"&gt;HelloCommand&lt;/span&gt;&amp;gt;(command =&amp;gt; &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(command.Message + &lt;span style="color:#a31515"&gt;&amp;quot; Guid: &amp;quot;&lt;/span&gt; + command.Guid));&lt;br&gt; &lt;br&gt; bus.Start();&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Create the bus and tell it which endpoint to listen to (which creates a local MSMQ queue if necessary) and tell it which message type to listen for and which delegate to kick off when such a message is received.&lt;/p&gt;  &lt;p&gt;Similarly, when doing a &lt;strong&gt;receive/reply&lt;/strong&gt;, you would have to create the bus on the sender side with a local endpoint and register a message-handler for replies, like this:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d63f6e83-aed9-4415-a01a-7ab8d97f3c4c" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; bus = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; MiniBuss.&lt;span style="color:#2b91af"&gt;ServiceBus&lt;/span&gt; { LocalEndpoint = &lt;span style="color:#a31515"&gt;&amp;quot;minibuss_sender1&amp;quot;&lt;/span&gt; };&lt;br&gt; &lt;br&gt; bus.RegisterMessageEndpoint&amp;lt;&lt;span style="color:#2b91af"&gt;HelloCommand&lt;/span&gt;&amp;gt;(&lt;span style="color:#a31515"&gt;&amp;quot;minibuss_receiver1@johan-dell-ssd&amp;quot;&lt;/span&gt;);&lt;br&gt; &lt;br&gt; bus.RegisterMessageHandler&amp;lt;&lt;span style="color:#2b91af"&gt;HelloResponse&lt;/span&gt;&amp;gt;(reply =&amp;gt; &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Reply from receiver: &amp;quot;&lt;/span&gt; + reply.Message));&lt;br&gt; &lt;br&gt; bus.Start();&lt;br&gt; &lt;br&gt; &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Sending command...&amp;quot;&lt;/span&gt;);&lt;br&gt; bus.Send(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HelloCommand&lt;/span&gt; { Guid = &lt;span style="color:#2b91af"&gt;Guid&lt;/span&gt;.NewGuid(), Message = &lt;span style="color:#a31515"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt; });&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The receiver would do a bus.reply() like this:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e2609164-3adf-4752-8d4f-d7aa51446180" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; bus = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ServiceBus&lt;/span&gt; { LocalEndpoint = &lt;span style="color:#a31515"&gt;&amp;quot;minibuss_receiver1&amp;quot;&lt;/span&gt; };&lt;br&gt; &lt;br&gt; bus.RegisterMessageHandler&amp;lt;&lt;span style="color:#2b91af"&gt;HelloCommand&lt;/span&gt;&amp;gt;(command =&amp;gt;&lt;br&gt; {&lt;br&gt;     &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(command.Message + &lt;span style="color:#a31515"&gt;&amp;quot; Guid: &amp;quot;&lt;/span&gt; + command.Guid);&lt;br&gt; &lt;br&gt;     bus.Reply(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HelloResponse&lt;/span&gt; { Guid = &lt;span style="color:#2b91af"&gt;Guid&lt;/span&gt;.NewGuid(), Message = &lt;span style="color:#a31515"&gt;&amp;quot;Hello back!&amp;quot;&lt;/span&gt; });&lt;br&gt; });&lt;br&gt; &lt;br&gt; bus.Start();&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The MiniBus also supports &lt;strong&gt;publish&lt;/strong&gt; to multiple subscribers. A simple publisher would create a bus with a local endpoint (to receive subscribe/unsubscribe commands), tell it to handle subscriptions for a certain event, then start publishing something every 5 seconds (as an example):&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8e2c90a7-7645-4d2a-a34d-8a850245d8a5" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; bus = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; MiniBuss.&lt;span style="color:#2b91af"&gt;ServiceBus&lt;/span&gt; { LocalEndpoint = &lt;span style="color:#a31515"&gt;&amp;quot;minibuss_publisher1&amp;quot;&lt;/span&gt; };&lt;br&gt; &lt;br&gt; bus.HandleSubscriptionsFor&amp;lt;&lt;span style="color:#2b91af"&gt;SomethingHappenedEvent&lt;/span&gt;&amp;gt;();&lt;br&gt; &lt;br&gt; bus.Start();    &lt;br&gt; &lt;br&gt; &lt;span style="color:#2b91af"&gt;Task&lt;/span&gt;.Factory.StartNew(() =&amp;gt; PublishingThread(bus), &lt;span style="color:#2b91af"&gt;TaskCreationOptions&lt;/span&gt;.LongRunning);&lt;br&gt; &lt;br&gt; &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Done, press ENTER to exit&amp;quot;&lt;/span&gt;);&lt;br&gt; &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.ReadLine();&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;              &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:85028e28-2d61-410b-aad4-3802770c2117" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; PublishingThread(MiniBuss.&lt;span style="color:#2b91af"&gt;ServiceBus&lt;/span&gt; bus)&lt;br&gt; {&lt;br&gt;     &lt;span style="color:#0000ff"&gt;while&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;true&lt;/span&gt;)&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#2b91af"&gt;Thread&lt;/span&gt;.Sleep(5000);&lt;br&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; guid = &lt;span style="color:#2b91af"&gt;Guid&lt;/span&gt;.NewGuid();&lt;br&gt;         &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Publishing event with guid &amp;quot;&lt;/span&gt; + guid);&lt;br&gt;         bus.Publish(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;SomethingHappenedEvent&lt;/span&gt;() { Guid = guid, Sent = &lt;span style="color:#2b91af"&gt;DateTime&lt;/span&gt;.Now });&lt;br&gt;     }&lt;br&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Any clients interesting in &lt;strong&gt;subscribing&lt;/strong&gt; to events from the publisher would create a bus with a local endpoint, start the bus and then send a subscribe command to the publisher, telling it you’re interested in subscribing to a certain type of event and which delegate to handle it:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d8be7b59-5742-4b54-a002-bddbc79dc7e2" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; bus = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; MiniBuss.&lt;span style="color:#2b91af"&gt;ServiceBus&lt;/span&gt; {LocalEndpoint = &lt;span style="color:#a31515"&gt;&amp;quot;minibuss_subscriber1&amp;quot;}&lt;/span&gt;;&lt;br&gt; &lt;br&gt; bus.Start();&lt;br&gt; &lt;br&gt; bus.Subscribe&amp;lt;&lt;span style="color:#2b91af"&gt;SomethingHappenedEvent&lt;/span&gt;&amp;gt;(&lt;span style="color:#a31515"&gt;&amp;quot;minibuss_publisher1@localhost&amp;quot;&lt;/span&gt;, &lt;br&gt;     @event =&amp;gt; &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;something happened at {&lt;/span&gt;&lt;span style="color:#3cb371"&gt;0}&lt;/span&gt;&lt;span style="color:#a31515"&gt;, event id {&lt;/span&gt;&lt;span style="color:#3cb371"&gt;1}&lt;/span&gt;&lt;span style="color:#a31515"&gt;&amp;quot;&lt;/span&gt;,&lt;br&gt;         @event.Sent, @event.Guid));&lt;br&gt; &lt;br&gt; &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Waiting for events, press ENTER to exit&amp;quot;&lt;/span&gt;);&lt;br&gt; &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.ReadLine();&lt;br&gt; &lt;br&gt; bus.UnSubscribe&amp;lt;&lt;span style="color:#2b91af"&gt;SomethingHappenedEvent&lt;/span&gt;&amp;gt;(&lt;span style="color:#a31515"&gt;&amp;quot;minibuss_publisher1&amp;quot;&lt;/span&gt;);&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;strong&gt;Now, the question is, what do you think?&lt;/strong&gt; I &lt;em&gt;know&lt;/em&gt; there are issues with the code, like how to make message-handlers multi-threaded/concurrent without messing things up (it’s single threaded right now), and how to best handle exceptions, rollbacks and re-tries . Right now handling exceptions in send and receive works pretty well within a TransactionScope() together with ADO.NET, and if there’s an exception, the message is moved the an error-queue. No re-try or anything, only rollback and move to xxx_error. Also, the publisher doesn’t persist subscriptions, so if it is restarted subscribers wouldn’t know. You know, things like that.&lt;/p&gt;  &lt;p&gt;I’m a user of the micro-orm called &lt;a href="http://code.google.com/p/dapper-dot-net/" target="_blank"&gt;Dapper&lt;/a&gt; and like it a lot, so I’m thinking that maybe I should release this micro-bus as open source and see where people may take it, if anywhere? Maybe just down the drain because they figure out this service bus is dangerous to use and risk loosing messages or something (which would be extremely good to know :)&lt;/p&gt;  &lt;p&gt;Or maybe this code is useless because you already got nServiceBus and Rhino out there and coders don’t need another service bus?&lt;/p&gt;  &lt;p&gt;What do you say?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7917012" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Open+Source/default.aspx">Open Source</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Service+Bus/default.aspx">Service Bus</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/CQRS/default.aspx">CQRS</category></item><item><title>Pomodoro Timer for the Windows 7 TaskBar</title><link>http://weblogs.asp.net/jdanforth/archive/2011/08/16/pomodoro-timer-for-the-windows-7-taskbar.aspx</link><pubDate>Tue, 16 Aug 2011 11:08:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7912927</guid><dc:creator>jdanforth</dc:creator><slash:comments>7</slash:comments><description>&lt;p&gt;&lt;strong&gt;EDIT:&amp;nbsp; The code is now open source on codeplex, on &lt;a href="http://pomodorotaskbar.codeplex.com " target="_blank" mce_href="http://pomodorotaskbar.codeplex.com "&gt;http://pomodorotaskbar.codeplex.com &lt;/a&gt;There's a new version available&amp;nbsp;for download there too.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;If you’re into &lt;a href="http://www.pomodorotechnique.com/" target="_blank" mce_href="http://www.pomodorotechnique.com/"&gt;the Pomodoro technique&lt;/a&gt; and looking for a pretty simple out-of-the-way timer which sits in the Windows 7 taskbar and is controlled from the Win7 JumpList, this one might be worth trying out. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;NOTE: Icon overlays will NOT work if you're using small TaskBar icons!&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_69FABFDE.png" mce_href="http://weblogs.asp.net/blogs/jdanforth/image_69FABFDE.png"&gt;&lt;img style="border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_0F180A4B.png" width="334" height="43" mce_src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_0F180A4B.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s the timer looking like a tomato, with the remaining session minutes written out dynamically as icon overlay.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_34A187AC.png" mce_href="http://weblogs.asp.net/blogs/jdanforth/image_34A187AC.png"&gt;&lt;img style="border-width: 0px; margin: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_3E1A4622.png" width="244" height="192" mce_src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_3E1A4622.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The timer has a couple of JumpList Tasks which you can use to control it. The program works well when “pinned” to the taskbar if you prefer it.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_63A3C383.png" mce_href="http://weblogs.asp.net/blogs/jdanforth/image_63A3C383.png"&gt;&lt;img style="border-width: 0px; margin: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_5420B1B4.png" width="244" height="164" mce_src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_5420B1B4.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can also control the timer from the main window with one large action-button (stop, start, stop ringing and restart session).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_12A5FF5B.png" mce_href="http://weblogs.asp.net/blogs/jdanforth/image_12A5FF5B.png"&gt;&lt;img style="border-width: 0px; margin: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_0CEAE5B5.png" width="244" height="164" mce_src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_0CEAE5B5.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;When the timer is stopped, you can just click on the remaining minutes-textbox and change the default session length to whatever you like. The value is stored.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_1D82E0A3.png" mce_href="http://weblogs.asp.net/blogs/jdanforth/image_1D82E0A3.png"&gt;&lt;img style="border-width: 0px; margin: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_7503FE8E.png" width="244" height="51" mce_src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_7503FE8E.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;When the session is ended, the window flashes, the tomato shakes and a ringing sound is played a few times to get your attention. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;, this is a very simple program which I’m planning to release as open source when I’ve received some feedback. I prefer to keep it simple, but may add session logging. The name as well as the looks may change. .NET 4.0 is required.&lt;/p&gt;  &lt;div style="margin: 0px; padding: 0px; float: none; display: inline;" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:894107a9-6eca-4992-92a8-652e78cd280a" class="wlWriterEditableSmartContent"&gt;&lt;p&gt;Download the Pomodoro Timer: &lt;a href="http://pomodorotaskbar.codeplex.com/releases/view/71998"&gt;http://pomodorotaskbar.codeplex.com/releases/view/71998&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7912927" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Open+Source/default.aspx">Open Source</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/.NET+4.0/default.aspx">.NET 4.0</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/Pomodoro/default.aspx">Pomodoro</category></item><item><title>Create Tag-Cloud from RSS Feed in ASP.NET MVC</title><link>http://weblogs.asp.net/jdanforth/archive/2011/08/08/create-tag-cloud-from-rss-feed-in-asp-net-mvc.aspx</link><pubDate>Mon, 08 Aug 2011 11:40:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7901759</guid><dc:creator>jdanforth</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Say you want to generate your own tag-cloud from a list of categories or tags you pull from an RSS-feed or similar. This is one way to do it. I’m using ASP.NET MVC for this sample which creates a simple tag-cloud in a Razor-view with HTML looking something like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_0507121F.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_3CD95642.png" width="436" height="239" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The controller-code to start out with looks like this, where you read in the RSS-feed into a &lt;strong&gt;SyndicationFeed&lt;/strong&gt; class, then pull out and flatten all the categories you have in that feed. Then group all those categories and count them to build up this simple view-model which is a Dictionary of category and percentage:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e018791a-8bdf-4fb2-8e96-7476fe3d5b1d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HomeController&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;Controller&lt;/span&gt;&lt;br&gt; {&lt;br&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ActionResult&lt;/span&gt; Index()&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#008000"&gt;//get feed&lt;/span&gt;&lt;br&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; feed = &lt;span style="color:#2b91af"&gt;SyndicationFeed&lt;/span&gt;.Load(&lt;span style="color:#2b91af"&gt;XmlReader&lt;/span&gt;.Create(&lt;span style="color:#a31515"&gt;&amp;quot;http://blog.irm.se/blogs/MainFeed.aspx&amp;quot;&lt;/span&gt;));&lt;br&gt; &lt;br&gt;         &lt;span style="color:#008000"&gt;//get flat list of all categories/tags in the feed&lt;/span&gt;&lt;br&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; categoriesList = feed.Items.SelectMany(item =&amp;gt; item.Categories).Select(category =&amp;gt; category.Name);&lt;br&gt; &lt;br&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; categoryGroups = categoriesList.GroupBy(category =&amp;gt; category);&lt;br&gt; &lt;br&gt;         &lt;span style="color:#0000ff"&gt;decimal&lt;/span&gt; maxNrOfACategory = categoryGroups.Max(w =&amp;gt; w.Count());&lt;br&gt; &lt;br&gt;         &lt;span style="color:#008000"&gt;//build a dictionary with category/percentage of all categories&lt;/span&gt;&lt;br&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; tagCloudDictionary = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;int&lt;/span&gt;&amp;gt;();&lt;br&gt;         &lt;span style="color:#0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; tag &lt;span style="color:#0000ff"&gt;in&lt;/span&gt; categoryGroups)&lt;br&gt;         {&lt;br&gt;             &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; percent = (tag.Count() / maxNrOfACategory) * 100;&lt;br&gt;             tagCloudDictionary.Add(tag.Key, (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)percent);&lt;br&gt;         }&lt;br&gt; &lt;br&gt;         &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; View(tagCloudDictionary);&lt;br&gt;     }&lt;br&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;p&gt;So now we got this view-model which is a &lt;strong&gt;Dictionary&amp;lt;string,int&amp;gt;&lt;/strong&gt; and contains category/percentage data like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/jdanforth/image_62CF0698.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/jdanforth/image_thumb_21C08734.png" width="251" height="328" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So all we need to do is create some kind of cloud in HTML or similar in the view. One way of doing it is this, which creates the output shown at the top:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5be2cc55-9b3d-4844-ac07-c8de04ab8194" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffff00"&gt;@model &lt;/span&gt;&lt;span style="color:#2b91af"&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;int&lt;/span&gt;&amp;gt;&lt;br&gt; &lt;br&gt; &lt;span style="background:#ffff00"&gt;@{&lt;/span&gt;&lt;br&gt;     ViewBag.Title = &lt;span style="color:#a31515"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;;&lt;br&gt; }&lt;br&gt; &lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;h2&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;Tag cloud&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;h2&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt;width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;: 400px; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;font-size&lt;/span&gt;&lt;span style="color:#0000ff"&gt;: 25px;&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffff00"&gt;@&lt;/span&gt;&lt;span style="color:#0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; tag &lt;span style="color:#0000ff"&gt;in&lt;/span&gt; Model)&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;span&lt;/span&gt; &lt;span style="color:#ff0000"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;font-size: &lt;/span&gt;&lt;span style="background:#ffff00"&gt;@(&lt;/span&gt;&lt;span style="color:#0000ff"&gt;tag.Value / 2 + 50&lt;/span&gt;&lt;span style="background:#ffff00"&gt;)&lt;/span&gt;&lt;span style="color:#0000ff"&gt;%; &amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffff00"&gt;@&lt;/span&gt;&lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (tag.Value &amp;gt; 10)&lt;br&gt;         {&lt;br&gt;             &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;span&lt;/span&gt; &lt;span style="color:#ff0000"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;font-weight&lt;/span&gt;&lt;span style="color:#0000ff"&gt;: bold;&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffff00"&gt;@&lt;/span&gt;tag.Key &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;span&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;         }&lt;br&gt;         &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;br&gt;         {&lt;br&gt;             &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;span&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffff00"&gt;@&lt;/span&gt;tag.Key &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;span&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;         }&lt;br&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;span&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     }&lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Obviously, to be able to click on a tag and so on you need to create a richer view-model, I just wanted to show how I grab and count the tags from the feed &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://weblogs.asp.net/blogs/jdanforth/wlEmoticon-smile_79ADD814.png" /&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7901759" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jdanforth/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/jdanforth/archive/tags/c_2300_/default.aspx">c#</category></item></channel></rss>