<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JAPF</title>
	<atom:link href="http://www.japf.fr/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.japf.fr</link>
	<description>Jeremy Alles Presentation Foundation: WPF, Silverlight, Windows Phone 7, Windows 8</description>
	<lastBuildDate>Mon, 06 May 2013 14:08:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>RSA cryptography between a WinRT and a .Net app</title>
		<link>http://www.japf.fr/2013/05/rsa-cryptography-between-a-winrt-and-a-dotnet-app/</link>
		<comments>http://www.japf.fr/2013/05/rsa-cryptography-between-a-winrt-and-a-dotnet-app/#comments</comments>
		<pubDate>Mon, 06 May 2013 14:08:20 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[WinRT]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1523</guid>
		<description><![CDATA[In this blog post, I share how I managed to enable RSA cryptography between a .Net app (actually a WCF service hosted in Azure) and WinRT app. I found few entries on the Internet talking about this issue but none of them solved my issue directly. In particular, I had to use some options I [...]]]></description>
				<content:encoded><![CDATA[<p>In this blog post, I share how I managed to enable RSA cryptography between a .Net app (actually a WCF service hosted in Azure) and WinRT app. I found few entries on the Internet talking about this issue but none of them solved my issue directly. In particular, I had to use some options I wasn&#8217;t using before the interop need with WinRT. That&#8217;s the reason behind this blog post.</p>
<p><strong>Context</strong></p>
<p>The following diagram showcase the need I have in my scenario:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2013/05/WinRT-encryption1.png" rel="lightbox[1523]"><img class="alignnone  wp-image-1525" alt="WinRT encryption" src="http://www.japf.fr/wp-content/uploads/2013/05/WinRT-encryption1.png" width="547" height="137" /></a></p>
<p>I need to securely transfer data from a WinRT app to a .Net server app. The transport mechanism is out the scope of this article but it worth noting I&#8217;m using this approach because I cannot use HTTPS.</p>
<p>In order to give you a complete implementation I will be sharing in the rest of this article this way (encrypted data from WinRT to the server) and the other way around. So for each platform, you have the creation of the key pair, the encryption and the description method.</p>
<p><strong>WinRT</strong></p>
<p><em>Create key pairs</em></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1523code7'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p15237"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p1523code7"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> Tuple<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> WinRTCreateKeyPair<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    AsymmetricKeyAlgorithmProvider asym <span style="color: #008000;">=</span> AsymmetricKeyAlgorithmProvider<span style="color: #008000;">.</span><span style="color: #0000FF;">OpenAlgorithm</span><span style="color: #008000;">&#40;</span>AsymmetricAlgorithmNames<span style="color: #008000;">.</span><span style="color: #0000FF;">RsaPkcs1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    CryptographicKey key <span style="color: #008000;">=</span> asym<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateKeyPair</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1024</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    IBuffer privateKeyBuffer <span style="color: #008000;">=</span> key<span style="color: #008000;">.</span><span style="color: #0000FF;">Export</span><span style="color: #008000;">&#40;</span>CryptographicPrivateKeyBlobType<span style="color: #008000;">.</span><span style="color: #0000FF;">Capi1PrivateKey</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    IBuffer publicKeyBuffer <span style="color: #008000;">=</span> key<span style="color: #008000;">.</span><span style="color: #0000FF;">ExportPublicKey</span><span style="color: #008000;">&#40;</span>CryptographicPublicKeyBlobType<span style="color: #008000;">.</span><span style="color: #0000FF;">Capi1PublicKey</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> privateKeyBytes<span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> publicKeyBytes<span style="color: #008000;">;</span>
&nbsp;
    CryptographicBuffer<span style="color: #008000;">.</span><span style="color: #0000FF;">CopyToByteArray</span><span style="color: #008000;">&#40;</span>privateKeyBuffer, <span style="color: #0600FF; font-weight: bold;">out</span> privateKeyBytes<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    CryptographicBuffer<span style="color: #008000;">.</span><span style="color: #0000FF;">CopyToByteArray</span><span style="color: #008000;">&#40;</span>publicKeyBuffer, <span style="color: #0600FF; font-weight: bold;">out</span> publicKeyBytes<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">string</span> privateKey <span style="color: #008000;">=</span> Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">ToBase64String</span><span style="color: #008000;">&#40;</span>privateKeyBytes<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">string</span> publicKey <span style="color: #008000;">=</span> Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">ToBase64String</span><span style="color: #008000;">&#40;</span>publicKeyBytes<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">new</span> Tuple<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>privateKey, publicKey<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><em>Encrypt</em></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1523code8'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p15238"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p1523code8"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> WinRTEncrypt<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> publicKey, <span style="color: #6666cc; font-weight: bold;">string</span> data<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    IBuffer keyBuffer <span style="color: #008000;">=</span> CryptographicBuffer<span style="color: #008000;">.</span><span style="color: #0000FF;">DecodeFromBase64String</span><span style="color: #008000;">&#40;</span>publicKey<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    AsymmetricKeyAlgorithmProvider asym <span style="color: #008000;">=</span> AsymmetricKeyAlgorithmProvider<span style="color: #008000;">.</span><span style="color: #0000FF;">OpenAlgorithm</span><span style="color: #008000;">&#40;</span>AsymmetricAlgorithmNames<span style="color: #008000;">.</span><span style="color: #0000FF;">RsaPkcs1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    CryptographicKey key <span style="color: #008000;">=</span> asym<span style="color: #008000;">.</span><span style="color: #0000FF;">ImportPublicKey</span><span style="color: #008000;">&#40;</span>keyBuffer, CryptographicPublicKeyBlobType<span style="color: #008000;">.</span><span style="color: #0000FF;">Capi1PublicKey</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    IBuffer plainBuffer <span style="color: #008000;">=</span> CryptographicBuffer<span style="color: #008000;">.</span><span style="color: #0000FF;">ConvertStringToBinary</span><span style="color: #008000;">&#40;</span>data, BinaryStringEncoding<span style="color: #008000;">.</span><span style="color: #0000FF;">Utf8</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    IBuffer encryptedBuffer <span style="color: #008000;">=</span> CryptographicEngine<span style="color: #008000;">.</span><span style="color: #0000FF;">Encrypt</span><span style="color: #008000;">&#40;</span>key, plainBuffer, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> encryptedBytes<span style="color: #008000;">;</span>
    CryptographicBuffer<span style="color: #008000;">.</span><span style="color: #0000FF;">CopyToByteArray</span><span style="color: #008000;">&#40;</span>encryptedBuffer, <span style="color: #0600FF; font-weight: bold;">out</span> encryptedBytes<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> encryptedBytes<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><em>Decrypt</em></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1523code9'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p15239"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p1523code9"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">string</span> WinRTDecrypt<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> privateKey, <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> data<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    IBuffer keyBuffer <span style="color: #008000;">=</span> CryptographicBuffer<span style="color: #008000;">.</span><span style="color: #0000FF;">DecodeFromBase64String</span><span style="color: #008000;">&#40;</span>privateKey<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    AsymmetricKeyAlgorithmProvider asym <span style="color: #008000;">=</span> AsymmetricKeyAlgorithmProvider<span style="color: #008000;">.</span><span style="color: #0000FF;">OpenAlgorithm</span><span style="color: #008000;">&#40;</span>AsymmetricAlgorithmNames<span style="color: #008000;">.</span><span style="color: #0000FF;">RsaPkcs1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    CryptographicKey key <span style="color: #008000;">=</span> asym<span style="color: #008000;">.</span><span style="color: #0000FF;">ImportKeyPair</span><span style="color: #008000;">&#40;</span>keyBuffer, CryptographicPrivateKeyBlobType<span style="color: #008000;">.</span><span style="color: #0000FF;">Capi1PrivateKey</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    IBuffer plainBuffer <span style="color: #008000;">=</span> CryptographicEngine<span style="color: #008000;">.</span><span style="color: #0000FF;">Decrypt</span><span style="color: #008000;">&#40;</span>key, data<span style="color: #008000;">.</span><span style="color: #0000FF;">AsBuffer</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> plainBytes<span style="color: #008000;">;</span>
    CryptographicBuffer<span style="color: #008000;">.</span><span style="color: #0000FF;">CopyToByteArray</span><span style="color: #008000;">&#40;</span>plainBuffer, <span style="color: #0600FF; font-weight: bold;">out</span> plainBytes<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> Encoding<span style="color: #008000;">.</span><span style="color: #0000FF;">UTF8</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetString</span><span style="color: #008000;">&#40;</span>plainBytes, <span style="color: #FF0000;">0</span>, plainBytes<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><strong>.Net</strong></p>
<p><em>Create key pairs</em></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1523code10'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p152310"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p1523code10"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> Tuple<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> DotNetCreateKeyPair<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    CspParameters cspParams <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> CspParameters <span style="color: #008000;">&#123;</span> ProviderType <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span> <span style="color: #008080; font-style: italic;">/* PROV_RSA_FULL */</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
    RSACryptoServiceProvider rsaProvider <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> RSACryptoServiceProvider<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1024</span>, cspParams<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">string</span> publicKey <span style="color: #008000;">=</span> Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">ToBase64String</span><span style="color: #008000;">&#40;</span>rsaProvider<span style="color: #008000;">.</span><span style="color: #0000FF;">ExportCspBlob</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">string</span> privateKey <span style="color: #008000;">=</span> Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">ToBase64String</span><span style="color: #008000;">&#40;</span>rsaProvider<span style="color: #008000;">.</span><span style="color: #0000FF;">ExportCspBlob</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">new</span> Tuple<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>privateKey, publicKey<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><em>Encrypt</em></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1523code11'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p152311"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p1523code11"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> DotNetEncrypt<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> publicKey, <span style="color: #6666cc; font-weight: bold;">string</span> data<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    CspParameters cspParams <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> CspParameters <span style="color: #008000;">&#123;</span> ProviderType <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span> <span style="color: #008080; font-style: italic;">/* PROV_RSA_FULL */</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
    RSACryptoServiceProvider rsaProvider <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> RSACryptoServiceProvider<span style="color: #008000;">&#40;</span>cspParams<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    rsaProvider<span style="color: #008000;">.</span><span style="color: #0000FF;">ImportCspBlob</span><span style="color: #008000;">&#40;</span>Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">FromBase64String</span><span style="color: #008000;">&#40;</span>publicKey<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> plainBytes <span style="color: #008000;">=</span> Encoding<span style="color: #008000;">.</span><span style="color: #0000FF;">UTF8</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetBytes</span><span style="color: #008000;">&#40;</span>data<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> encryptedBytes <span style="color: #008000;">=</span> rsaProvider<span style="color: #008000;">.</span><span style="color: #0000FF;">Encrypt</span><span style="color: #008000;">&#40;</span>plainBytes, <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> encryptedBytes<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><em>Decrypt</em></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1523code12'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p152312"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p1523code12"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">string</span> DotNetDecrypt<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> privateKey, <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> encryptedBytes<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    CspParameters cspParams <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> CspParameters <span style="color: #008000;">&#123;</span> ProviderType <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span> <span style="color: #008080; font-style: italic;">/* PROV_RSA_FULL */</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
    RSACryptoServiceProvider rsaProvider <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> RSACryptoServiceProvider<span style="color: #008000;">&#40;</span>cspParams<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    rsaProvider<span style="color: #008000;">.</span><span style="color: #0000FF;">ImportCspBlob</span><span style="color: #008000;">&#40;</span>Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">FromBase64String</span><span style="color: #008000;">&#40;</span>privateKey<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> plainBytes <span style="color: #008000;">=</span> rsaProvider<span style="color: #008000;">.</span><span style="color: #0000FF;">Decrypt</span><span style="color: #008000;">&#40;</span>encryptedBytes, <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">string</span> plainText <span style="color: #008000;">=</span> Encoding<span style="color: #008000;">.</span><span style="color: #0000FF;">UTF8</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetString</span><span style="color: #008000;">&#40;</span>plainBytes, <span style="color: #FF0000;">0</span>, plainBytes<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> plainText<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Hope it helps <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2013/05/rsa-cryptography-between-a-winrt-and-a-dotnet-app/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using PowerShell to automate the build process of your Windows Phone app</title>
		<link>http://www.japf.fr/2013/03/using-powershell-to-automate-the-build-process-of-your-windows-phone-app/</link>
		<comments>http://www.japf.fr/2013/03/using-powershell-to-automate-the-build-process-of-your-windows-phone-app/#comments</comments>
		<pubDate>Wed, 13 Mar 2013 15:46:25 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1477</guid>
		<description><![CDATA[Another day another occasion to share a tip which comes with the development of my todo-list app 2Day. This time, I share a small PowerShell script I use in order to build the application. Of course the script will not work out of the box for you but it could be useful if you’re thinking [...]]]></description>
				<content:encoded><![CDATA[<p>Another day another occasion to share a tip which comes with the development of my todo-list app <a href="http://www.2day-app.com">2Day</a>. This time, I share a small PowerShell script I use in order to build the application. Of course the script will not work out of the box for you but it could be useful if you’re thinking about automating the generation of your application.</p>
<p><strong>Background: managing multiple versions</strong></p>
<p>Since release 1.5.0 there are two versions of 2Day: the lite version (free) and the standard version (paid). I switch from one configuration to another using two Build Configurations. When I want to build the Lite version I build using the Release Lite configuration while for the standard version I build in Release. The difference between the two is a conditional symbol.</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2013/03/2Day-Configurations.png" rel="lightbox[1477]"><img class="alignnone size-full wp-image-1480" alt="2Day-Configurations" src="http://www.japf.fr/wp-content/uploads/2013/03/2Day-Configurations.png" width="540" height="327" /></a></p>
<p>I also have a WP7 and a WP8. So for each official release, I must produce 4 XAPs:</p>
<ul>
<li><span style="line-height: 13px;">WP7 Lite</span></li>
<li>WP7 Full</li>
<li>WP8 Lite</li>
<li>WP8 Full</li>
</ul>
<p>This is the reason why I was thinking about automating this stuff !</p>
<p><strong>PowerShell script</strong></p>
<p>The script itself is very straightforward: I use MSBuild to build the Visual Studio Solution File (*.sln) using the 2 configurations I described earlier. Once a build is complete I move the generated XAPs to an output folder. As I said this script will NOT work out of the box for your but it could be used as an example. Here is the code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1477code14'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p147714"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
</pre></td><td class="code" id="p1477code14"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># usage is ./ScripName -version 1.5.0</span>
<span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$version</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;version&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$solution</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;2Day.sln&quot;</span>
<span style="color: #800080;">$msbuild</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe&quot;</span>
<span style="color: #008000;"># get the location of the script</span>
<span style="color: #800080;">$rootDir</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.Io.Path<span style="color: #000000;">&#93;</span>::GetDirectoryName<span style="color: #000000;">&#40;</span><span style="color: #800080;">$MyInvocation</span>.MyCommand.Path<span style="color: #000000;">&#41;</span>
<span style="color: #008000;"># build the location of the sln file. In my case this is under /Branches/WindowsPhone/versionunmber/</span>
<span style="color: #800080;">$baseDir</span> <span style="color: pink;">=</span> <span style="color: #800080;">$rootDir</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\Branches\WindowsPhone\&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$version</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\&quot;</span>
<span style="color: #008000;"># and the ouput is in a Build folder</span>
<span style="color: #800080;">$outputFolder</span> <span style="color: pink;">=</span> <span style="color: #800080;">$rootDir</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\Build\&quot;</span>
&nbsp;
<span style="color: #008000;"># if the output folder exists, delete it</span>
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>System.IO.Directory<span style="color: #000000;">&#93;</span>::Exists<span style="color: #000000;">&#40;</span><span style="color: #800080;">$outputFolder</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
 <span style="color: #000000;">&#91;</span>System.IO.Directory<span style="color: #000000;">&#93;</span>::Delete<span style="color: #000000;">&#40;</span><span style="color: #800080;">$outputFolder</span><span style="color: pink;">,</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span>
 <span style="color: #000000;">&#91;</span>System.IO.Directory<span style="color: #000000;">&#93;</span>::CreateDirectory<span style="color: #000000;">&#40;</span><span style="color: #800080;">$outputFolder</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">else</span>
<span style="color: #000000;">&#123;</span>
 <span style="color: #000000;">&#91;</span>System.IO.Directory<span style="color: #000000;">&#93;</span>::CreateDirectory<span style="color: #000000;">&#40;</span><span style="color: #800080;">$outputFolder</span><span style="color: #000000;">&#41;</span><span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Building 2Day version: &quot;</span> <span style="color: #800080;">$version</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Solution is at: &quot;</span>  <span style="color: #800080;">$baseDir</span><span style="color: #800080;">$solution</span>
&nbsp;
<span style="color: #008000;"># make sure our working directory is correct</span>
<span style="color: #008080; font-weight: bold;">cd</span> <span style="color: #800080;">$baseDir</span>
&nbsp;
<span style="color: #800080;">$configurations</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Release&quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;Release Lite&quot;</span>
<span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$configuration</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$configurations</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># prepare build command line</span>
	<span style="color: #800080;">$options</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;/noconsolelogger /m /p:Configuration=&quot;</span><span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$configuration</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot; /p:Platform=&quot;</span><span style="color: #800000;">&quot;Any CPU&quot;</span><span style="color: #800000;">&quot;&quot;</span>
&nbsp;
	<span style="color: #008000;"># prepare output path</span>
	<span style="color: #800080;">$releasePath1</span> <span style="color: pink;">=</span> <span style="color: #800080;">$baseDir</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;2Day.App.WP7\bin\&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$configuration</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\_2DayWP7.xap&quot;</span>
	<span style="color: #800080;">$outFile1</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;2Day_&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$version</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;_WP7_&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$configuration</span>.Replace<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot; &quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;_&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;.xap&quot;</span>
	<span style="color: #800080;">$releasePath2</span> <span style="color: pink;">=</span> <span style="color: #800080;">$baseDir</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;2Day.App.WP8\bin\&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$configuration</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\_2DayWP8.xap&quot;</span>
	<span style="color: #800080;">$outFile2</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;2Day_&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$version</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;_WP8_&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$configuration</span>.Replace<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot; &quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;_&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;.xap&quot;</span>
&nbsp;
	<span style="color: #008000;"># clean</span>
	<span style="color: #008080; font-weight: bold;">Write-Host</span> Perform cleaning...	
	<span style="color: #800080;">$clean</span> <span style="color: pink;">=</span> <span style="color: #800080;">$msbuild</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$solution</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$options</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; /t:Clean&quot;</span>
	<span style="color: #008080; font-weight: bold;">Invoke-Expression</span> <span style="color: #800080;">$clean</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>
&nbsp;
	<span style="color: #008000;"># build</span>
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Building with configuration&quot;</span>$configuration<span style="color: #800000;">&quot;...&quot;</span>
	<span style="color: #800080;">$build</span> <span style="color: pink;">=</span> <span style="color: #800080;">$msbuild</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$solution</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$options</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; /t:Build&quot;</span>
	<span style="color: #008080; font-weight: bold;">Invoke-Expression</span> <span style="color: #800080;">$build</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>
&nbsp;
	<span style="color: #008000;"># move the files that were built to the output folder</span>
	<span style="color: #800080;">$out1</span> <span style="color: pink;">=</span> <span style="color: #800080;">$outputFolder</span> <span style="color: pink;">+</span> <span style="color: #800080;">$outFile1</span>;
	<span style="color: #800080;">$out2</span> <span style="color: pink;">=</span> <span style="color: #800080;">$outputFolder</span> <span style="color: pink;">+</span> <span style="color: #800080;">$outFile2</span>;
	<span style="color: #000000;">&#91;</span>System.IO.File<span style="color: #000000;">&#93;</span>::<span style="color: #008080; font-weight: bold;">Copy</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$releasePath1</span><span style="color: pink;">,</span> <span style="color: #800080;">$out1</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#91;</span>System.IO.File<span style="color: #000000;">&#93;</span>::<span style="color: #008080; font-weight: bold;">Copy</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$releasePath2</span><span style="color: pink;">,</span> <span style="color: #800080;">$out2</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Output: &quot;</span> <span style="color: #800080;">$out1</span> <span style="color: #800080;">$out2</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008080; font-weight: bold;">cd</span> <span style="color: #800080;">$rootDir</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Done&quot;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2013/03/using-powershell-to-automate-the-build-process-of-your-windows-phone-app/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A Reactive Extension (Rx) use case in a Windows Phone app</title>
		<link>http://www.japf.fr/2013/03/a-reactive-extension-rx-use-case-in-a-windows-phone-app/</link>
		<comments>http://www.japf.fr/2013/03/a-reactive-extension-rx-use-case-in-a-windows-phone-app/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 12:07:24 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Rx]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[reactive extensions]]></category>
		<category><![CDATA[rx]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1468</guid>
		<description><![CDATA[While working on my todo-list application 2Day, I encountered a situation where Rx came to the rescue. Rx (Reactive Extension) is a framework which has been available for a couple of years now. It is possible to use it on the phone very easily. In this blog post, I share a piece of code which [...]]]></description>
				<content:encoded><![CDATA[<p>While working on my todo-list application <a href="http://www.2day-app.com">2Day</a>, I encountered a situation where <a href="http://msdn.microsoft.com/en-us/data/gg577609.aspx">Rx</a> came to the rescue. Rx (Reactive Extension) is a framework which has been available for a couple of years now. It is possible to use it on the phone very easily. In this blog post, I share a piece of code which use Rx to implement a specific feature in 2Day.</p>
<p>
2Day’s users have requested a search feature. The idea is simple: give the user a new page where he can type some text which then filters his tasks. Here is the feature in action in 2Day:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2013/03/2Day-global-search.png" rel="lightbox[1468]"><img src="http://www.japf.fr/wp-content/uploads/2013/03/2Day-global-search-180x300.png" alt="2Day - global search" width="180" height="300" class="alignnone size-medium wp-image-1469" /></a></p>
<p>
Even though it seems very basic, I wanted to add an extra feature: perform the search a couple of milliseconds after the user actually stops typing. This prevents the search result to blink while the user types. It turns out it’s very easy to implement this using Rx which is dedicated to manipulate stream of observable items. Here is the code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1468code16'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p146816"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p1468code16"><pre class="csharp" style="font-family:monospace;">var seq <span style="color: #008000;">=</span> Observable
    <span style="color: #008000;">.</span><span style="color: #0000FF;">FromEventPattern</span><span style="color: #008000;">&lt;</span>TextChangedEventArgs<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">textbox</span>, <span style="color: #666666;">&quot;TextChanged&quot;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">.</span><span style="color: #0000FF;">Throttle</span><span style="color: #008000;">&#40;</span>TimeSpan<span style="color: #008000;">.</span><span style="color: #0000FF;">FromMilliseconds</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">500</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">.</span><span style="color: #0000FF;">ObserveOnDispatcher</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">.</span><span style="color: #0000FF;">Subscribe</span><span style="color: #008000;">&#40;</span>e <span style="color: #008000;">=&gt;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">viewmodel</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SearchText</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">textbox</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>The first step is to create the observable sequence using the FromEventPattern method which can turn an event into an observable stream. Then the Throttle method allows to “calm down” the stream, by requiring the specified amount of time to be spent before sending the item in the output stream.</p>
<p>
This can be shown using the following diagram:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2013/03/RxExampleThrottle.png" rel="lightbox[1468]"><img src="http://www.japf.fr/wp-content/uploads/2013/03/RxExampleThrottle-300x123.png" alt="RxExampleThrottle" width="300" height="123" class="alignnone size-medium wp-image-1501" /></a></p>
<p>If the user presses quickly the letters &#8220;p&#8221;, &#8220;a&#8221;, &#8220;i&#8221; and &#8220;r&#8221; we will start the search only after the specified amount of time and not for each new letter. Notice that the subscribe method does not do a lot of things: it only sets a property on the ViewModel layer which actually performs the search.</p>
<p>Here is a simple yet useful use case for Rx. It’s very nice to have the library available out of the box on the phone. Hope it helps <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2013/03/a-reactive-extension-rx-use-case-in-a-windows-phone-app/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Tips and tricks when using voice recognition in a Windows Phone 8 app</title>
		<link>http://www.japf.fr/2013/01/tips-and-tricks-when-using-voice-recognition-in-a-windows-phone-8-app/</link>
		<comments>http://www.japf.fr/2013/01/tips-and-tricks-when-using-voice-recognition-in-a-windows-phone-8-app/#comments</comments>
		<pubDate>Sun, 27 Jan 2013 18:40:47 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[voice recognition]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1443</guid>
		<description><![CDATA[While working (again) on 2Day, I encountered small issues with voice recognition. The next version of 2Day will bring support for both speech recognition (use your voice to set the title of a task) and voice commands (speak to your phone to perform operations, for example: &#8220;2Day add a reminder tomorrow at 9PM&#8221;). While developing [...]]]></description>
				<content:encoded><![CDATA[<p>While working (again) on <a href="http://www.2day-app.com">2Day</a>, I encountered small issues with voice recognition. The next version of 2Day will bring support for both speech recognition (use your voice to set the title of a task) and voice commands (speak to your phone to perform operations, for example: &#8220;2Day add a reminder tomorrow at 9PM&#8221;).</p>
<p>While developing those new features I used two distinct API for voice recognition:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.phone.speech.recognition.speechrecognizer(v=vs.105).aspx">SpeechRecognizer</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.phone.speech.recognition.speechrecognizerui(v=vs.105).aspx">SpeechRecognizerUI</a></li>
</ul>
<p>The first one provides no UI while the second one includes a default GUI which is uniform across apps and utilities:</p>
<p><a href="http://www.japf.fr/2013/01/tips-and-tricks-when-using-voice-recognition-in-a-windows-phone-8-app/listenning/" rel="attachment wp-att-1444"><img class="alignnone size-medium wp-image-1444" alt="Listenning" src="http://www.japf.fr/wp-content/uploads/2013/01/Listenning-166x300.png" width="166" height="300" /></a></p>
<p><strong>Issue 1: stop music playback automatically</strong></p>
<p>In 2Day, I use the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.phone.speech.recognition.speechrecognizerui(v=vs.105).aspx">SpeechRecognizerUI</a> when the user must confirm a choice while seeing what is visible on the screen. When using those APIs I faced a first problem which is music playback is not stopped automatically during voice recognition. It turns out a simple API can be used for this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1443code18'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p144318"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p1443code18"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> PauseMusicPlayback<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">wasPlayingMusic</span> <span style="color: #008000;">=</span> MediaPlayer<span style="color: #008000;">.</span><span style="color: #0000FF;">State</span> <span style="color: #008000;">==</span> MediaState<span style="color: #008000;">.</span><span style="color: #0000FF;">Playing</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">wasPlayingMusic</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        FrameworkDispatcher<span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        MediaPlayer<span style="color: #008000;">.</span><span style="color: #0000FF;">Pause</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        FrameworkDispatcher<span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>            
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> ResumeMusicPlayback<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">wasPlayingMusic</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// it looks like FrameworkDispatcher.Update() is needed when using the MediaPlayer</span>
        FrameworkDispatcher<span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        MediaPlayer<span style="color: #008000;">.</span><span style="color: #0000FF;">Resume</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        FrameworkDispatcher<span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>With a simple boolean field, I can save before starting voice recognition if I will have to resume music playback.</p>
<p><strong>Issue 2: use default sound with SpeechRecognizer</strong></p>
<p>When using the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.phone.speech.recognition.speechrecognizer(v=vs.105).aspx">SpeechRecognizer</a> class (the one without the default UI) I faced another problems: start/end of voice recognition is not surrounded by the small system sound that indicates that the recognition has started/ended. I thought the easiest way to get this sound as a WAV file on my machine was to use an Audio Capturing tool such as <a href="http://audacity.sourceforge.net/">Audacity</a>.</p>
<p>Long story short: that was a bad idea. And it turns out&#8230; The original sound files are installed with the SDK !</p>
<p>If you browse the following directory C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Sounds you will be able to get the 2 WAV files ! And use them in your app (you can see my <a href="http://www.japf.fr/2010/08/sound-effect-in-wp7-sl-application/">older blog post</a> about how to play WAV file in a Silverlight Windows Phone app).</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2013/01/SoundFiles.png" rel="lightbox[1443]"><img class="alignnone size-full wp-image-1450" alt="SoundFiles" src="http://www.japf.fr/wp-content/uploads/2013/01/SoundFiles.png" width="165" height="50" /></a></p>
<p><em>Hope it helps <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2013/01/tips-and-tricks-when-using-voice-recognition-in-a-windows-phone-8-app/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Welcome 2013 :-)</title>
		<link>http://www.japf.fr/2012/12/welcome-2013/</link>
		<comments>http://www.japf.fr/2012/12/welcome-2013/#comments</comments>
		<pubDate>Mon, 31 Dec 2012 12:22:17 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[WinRT]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1435</guid>
		<description><![CDATA[This is the perfect time to take a look at what happened in the last few months as well as what&#8217;s on the roadmap for next year. So let&#8217;s start by taking a look at 2012&#8230; Events In February I went to the TechDays in Paris. I was speaker in a session about Performance optimization [...]]]></description>
				<content:encoded><![CDATA[<p>This is the perfect time to take a look at what happened in the last few months as well as what&#8217;s on the roadmap for next year. So let&#8217;s start by taking a look at 2012&#8230;</p>
<p><strong>Events</strong></p>
<ul>
<li>In February I went to the TechDays in Paris. I was speaker in a session about <a href="http://www.microsoft.com/fr-fr/showcase/details.aspx?uuid=862ec731-bc87-4547-8739-b95f805e7404">Performance optimization for Windows Phone application</a></li>
</ul>
<p><a href="http://www.japf.fr/2012/12/welcome-2013/techdays12/" rel="attachment wp-att-1440"><img class="alignnone size-medium wp-image-1440" alt="techdays12" src="http://www.japf.fr/wp-content/uploads/2012/12/techdays12-300x198.png" width="300" height="198" /></a></p>
<ul>
<li>In November, I gave a presentation about Windows Phone 8 at <a href="http://www.sfeir.com/networking/sfeirplays/">SFEIR Plays</a></li>
</ul>
<p><a href="http://www.japf.fr/2012/12/welcome-2013/sfeir-plays-3/" rel="attachment wp-att-1439"><img class="alignnone size-medium wp-image-1439" alt="sfeir plays" src="http://www.japf.fr/wp-content/uploads/2012/12/sfeir-plays2-300x208.jpg" width="300" height="208" /></a></p>
<p><strong>Blog posts</strong></p>
<p>The last year I blogged mostly about Windows Phone stuff. This is not a surprise as I&#8217;m busy (on my personal time&#8230;) working for my <a href="http://www.2day-app.com">2Day todo-list application</a>. I&#8217;m finalizing a major release that should be submitted to the marketplace soon with a ton of new features and improvement (several blog posts should highlight some topics from a developer point of view).</p>
<p>Here is the full list of article (oldest first):</p>
<ul>
<li><a href="http://www.japf.fr/2012/01/if-you-like-typing-xaml-you-will-love-resharper-6-1/">If you like typing XAML you will love ReSharper 6.1 !</a></li>
<li><a href="http://www.japf.fr/2012/01/resharper-and-code-generation/">ReSharper and code generation</a></li>
<li><a href="http://www.japf.fr/2012/01/windows-phone-performance-analysis-optimization-during-techdays/">Windows Phone performance analysis &amp; optimization during TechDays</a></li>
<li><a href="http://www.japf.fr/2012/02/developping-an-app-for-the-windows-phone-platform/">Developping an app for the Windows Phone platform</a></li>
<li><a href="http://www.japf.fr/2012/02/windows-phone-vnext-windows-8-next-week/">Windows Phone vNext &amp; Windows 8 next week</a></li>
<li><a href="http://www.japf.fr/2012/02/windows-phone-tango-7-1-1/">Windows Phone Tango (7.1.1)</a></li>
<li><a href="http://www.japf.fr/2012/03/introducing-the-pivotindicator-control/">Introducing the PivotIndicator control for Windows Phone</a></li>
<li><a href="http://www.japf.fr/2012/03/wp7-perf-tip-translate-transforms/">WP7 performance tip: translate transforms</a></li>
<li><a href="http://www.japf.fr/2012/03/mvvm-framework-explorer-updated-2/">MVVM framework explorer updated !</a></li>
<li><a href="http://www.japf.fr/2012/04/hello-world-winrt/">Hello World, WinRT !</a></li>
<li><a href="http://www.japf.fr/2012/04/a-lap-around-tfs-online/">A lap around Team Foundation Service online</a></li>
<li><a href="http://www.japf.fr/2012/04/porting-a-silverlight-windows-phone-app-to-winrt-in-9hours/">Hacking for fun: porting a Silverlight Windows Phone app to WinRT in 9hours</a></li>
<li><a href="http://www.japf.fr/2012/04/introducing-2day-a-fast-fluid-todo-list-wp7-app/">Introducing 2Day: a fast &amp; fluid todo-list WP7 app</a></li>
<li><a href="http://www.japf.fr/2012/07/mvp2012-2013/">MVP 2012-2013 !</a></li>
<li><a href="http://www.japf.fr/2012/09/random-argumentexception-in-a-windows-phone-7-application/">Random ArgumentException in a Windows Phone 7 application</a></li>
<li><a href="http://www.japf.fr/2012/09/sql-database-version-management-in-a-windows-phone-7-application/">SQL database version management in a Windows Phone 7 application</a></li>
<li><a href="http://www.japf.fr/2012/09/wp7-handling-events-in-the-items-of-listbox/">Handling events in the items of a ListBox (Windows Developer Show podcast challenge)</a></li>
<li><a href="http://www.japf.fr/2012/10/animating-item-selection-in-a-wp7-application/">Animating item selection in a WP7 application</a></li>
<li><a href="http://www.japf.fr/2012/10/fun-with-ildasm-and-ilasm-tweaking-the-code-of-an-existing-library/">Fun with ILDASM and ILASM: tweaking the code of an existing library</a></li>
<li><a href="http://www.japf.fr/2012/10/welcome-windows-phone-8-0-sdk/">Welcome Windows Phone 8.0 SDK</a></li>
<li><a href="http://www.japf.fr/2012/11/meet-me-at-sfeirplays-paris-2811-talking-wp8/">Meet me at SFEIRPlays Paris 28/11 talking WP8</a></li>
<li><a href="http://www.japf.fr/2012/12/wanted-developers-for-2da/">Wanted: Windows Phone / Windows 8 developers for 2Day !</a></li>
<li><a href="http://www.japf.fr/2012/12/updating-the-live-tiles-when-the-exits-wp8-weirdness/">Updating the live tiles when the exits: WP8 weirdness</a></li>
</ul>
<p><strong>Next year</strong></p>
<p>2013 should very busy too <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<ul>
<li>In mid-February, I will speak again during the TechDays in Paris. The topic is the same as last year: performance optimization for Windows Phone applications. However, with Windows Phone 8 we&#8217;ve plenty of new topics to cover !</li>
<li>In late-February I will fly to Redmond for the <a href="http://www.2013mvpsummit.com/">MVP Summit 2013</a>. It will be my sedond time there. As aways, all the content will be under NDA&#8230; I will share a room with my friend <a href="http://advertboy.wordpress.com/">Jose Fajardo</a> I met at //BUILD/ 2011 !</li>
<li>In March, I should setup an event with my company and Microsoft in Grenoble talking about Windows 8 and Windows Phone 8</li>
</ul>
<p>I&#8217;m still deeply invested with 2Day so hopefully you should see more tips and tricks about Windows Phone. As a Windows 8 version is also on its way, that should give me many reasons to write new blog posts.</p>
<p>Happy new year dear readers !</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2012/12/welcome-2013/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating the live tiles when the exits: WP8 weirdness</title>
		<link>http://www.japf.fr/2012/12/updating-the-live-tiles-when-the-exits-wp8-weirdness/</link>
		<comments>http://www.japf.fr/2012/12/updating-the-live-tiles-when-the-exits-wp8-weirdness/#comments</comments>
		<pubDate>Thu, 27 Dec 2012 21:54:55 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1425</guid>
		<description><![CDATA[While working on the next version of my todo-list Windows Phone app 2Day, I encountered a strange issue with live tiles management I&#8217;m sharing in this blog post&#8230; Background You can manage tiles of a Windows Phone application in several ways. You can setup the tile with a remote image URI that will be fetched [...]]]></description>
				<content:encoded><![CDATA[<p>While working on the next version of my todo-list Windows Phone app <a href="http://www.2day-app.com">2Day</a>, I encountered a strange issue with live tiles management I&#8217;m sharing in this blog post&#8230;</p>
<p><a href="http://www.japf.fr/2012/12/updating-the-live-tiles-when-the-exits-wp8-weirdness/tiles/" rel="attachment wp-att-1426"><img alt="tiles" src="http://www.japf.fr/wp-content/uploads/2012/12/tiles.png" width="549" height="166" /></a></p>
<p><strong>Background</strong></p>
<p>You can manage tiles of a Windows Phone application in several ways. You can setup the tile with a remote image URI that will be fetched and updated by the system. This is useful for example when the same tile is pushed to many users (for example in a news reader app). You can also setup the tile with a local image. In that case, you can generate the image dynamically on the phone based on specific user&#8217;s information.</p>
<p>This is what the later option that is used in 2Day:</p>
<p><a href="http://www.japf.fr/2012/12/updating-the-live-tiles-when-the-exits-wp8-weirdness/2day-tiles/" rel="attachment wp-att-1429"><img class="alignnone size-medium wp-image-1429" alt="2Day tiles" src="http://www.japf.fr/wp-content/uploads/2012/12/2Day-tiles-300x234.png" width="300" height="234" /></a></p>
<p>The workflow to do that is the following:</p>
<ul>
<li>the user exits the app</li>
<li>an image is generated using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap(v=vs.95).aspx">WritableBitmap</a> class</li>
<li>the image is saved in the local storage of the app</li>
<li>the tile is updated using the <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.shell.shelltile(v=vs.92).aspx">ShellTile</a> API</li>
</ul>
<p><strong>Upgrading 2Day to Windows Phone 8</strong></p>
<p>While upgrading 2Day to Windows Phone 8, I decided to leverage fast-resume. Fast-resume is a new capability that can be used by Windows Phone applications. It allows to reuse the latest instance of the app when the user presses the tile instead of creating a new instance each time. All you have to do is to set the <em>ActivationPolicy</em> attribute<em> </em>to <em>Resume</em> in the WMAppManifest.xml file:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1425code20'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p142520"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1425code20"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DefaultTask</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;_default&quot;</span> <span style="color: #000066;">NavigationPage</span>=<span style="color: #ff0000;">&quot;/View/HomePage.xaml&quot;</span> <span style="color: #000066;">ActivationPolicy</span>=<span style="color: #ff0000;">&quot;Resume&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p><strong>The issue</strong></p>
<p>The problem I had was that after my app was suspended, it wasn&#8217;t able to start over with fast-resume.</p>
<p>The app was stuck in a &#8220;Resuming&#8230;&#8221; dialog. After several hours tweaking the code, I found out the issue disappeared when I removed the code which updated the live tile&#8230; Strange isn&#8217;t it ? Tweaking more the code, I found out it was the use of the WritableBitmap that was the cause of this issue. I searched over the Internet for a couple of days, asked in new dedicated topics on MSDN <a href="http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/aec0702b-787d-48ac-a1a9-9d34b3c6465a">forums</a> but no one had a solution.</p>
<p><strong>My workaround</strong></p>
<p>I finally decided to move the code which updates the tiles from the <em>Deactivated </em>event of the <em>Application</em> to the <em>OnNavigatedFrom</em> method of the main page of my app.</p>
<p>And that did the trick ! It&#8217;s working like a charm now <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Conclusion</strong></p>
<p>If you have a Windows Phone app and you&#8217;re updating tiles locally on the phone&#8230; Make sure to update your tiles when you&#8217;re navigating away from the main page and not in the Deactivated event <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I&#8217;m not sure what is causing the problem&#8230; but it looks like I&#8217;m not the only one facing it as I was contacted on Twitter about the problem.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2012/12/updating-the-live-tiles-when-the-exits-wp8-weirdness/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wanted: Windows Phone / Windows 8 developers for 2Day !</title>
		<link>http://www.japf.fr/2012/12/wanted-developers-for-2da/</link>
		<comments>http://www.japf.fr/2012/12/wanted-developers-for-2da/#comments</comments>
		<pubDate>Mon, 03 Dec 2012 12:34:24 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1406</guid>
		<description><![CDATA[Almost one year ago, I decided to create a simple but efficient todo list application for Windows Phone 7. In April 2012, I released 2Day, a fast and fluid todo list application. Today, while I’m busy preparing a new version which leverage new stuff available in Windows Phone 8 I also have big plans for [...]]]></description>
				<content:encoded><![CDATA[<p>Almost one year ago, I decided to create a simple but efficient todo list application for Windows Phone 7. In April 2012, I released <a href="www.2day-app.com">2Day</a>, a <em>fast and fluid todo list</em> application. Today, while I’m busy preparing a new version which leverage new stuff available in Windows Phone 8 I also have big plans for Windows 8.</p>
<p>And now, that just too much for a single man. This is why, <strong>I’m now actively looking for a couple of developers who would like to join me in the 2Day development team!</strong></p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/12/allscreens-1024x2621.png" rel="lightbox[1406]"><img class="alignnone size-full wp-image-1409" title="allscreens-1024x262" src="http://www.japf.fr/wp-content/uploads/2012/12/allscreens-1024x2621.png" alt="" width="1024" height="262" /></a></p>
<p>If you:</p>
<ul>
<li>Have development experience in C# and XAML (WPF, Silverlight, Windows Phone or Windows 8)</li>
<li>Want to work on an interesting app full of innovative features</li>
<li>Speak English or French</li>
</ul>
<div>You will enjoy:</div>
<div>
<ul>
<li>the latest cool technologies available</li>
<li>working in a international context (2Day is localized in 5 languages)</li>
<li>engaging directly with 2Day&#8217;s users through the <a href="http://2day.uservoice.com">UserVoice</a> website</li>
<li>organize you work with the team</li>
<li>build the Windows 8 app from the ground up</li>
</ul>
</div>
<p>Note: I’m not offering full time job here. <a href="www.2day-app.com">2Day</a> is a personal development project I’m doing on my free time <img src='http://www.japf.fr/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Please drop me an email using the <a href="http://www.japf.fr/contact/">Contact</a> form or via <a href="https://twitter.com/jalpf">Twitter</a>. I Hope to get in touch with you soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2012/12/wanted-developers-for-2da/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Meet me at SFEIRPlays Paris 28/11 talking WP8</title>
		<link>http://www.japf.fr/2012/11/meet-me-at-sfeirplays-paris-2811-talking-wp8/</link>
		<comments>http://www.japf.fr/2012/11/meet-me-at-sfeirplays-paris-2811-talking-wp8/#comments</comments>
		<pubDate>Mon, 19 Nov 2012 20:41:39 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1400</guid>
		<description><![CDATA[On November 28th I be speaking at an event organized by my very good friend Aline. SFEIRPlays is a free event opened to anyone (free registration is mandatory thought). You can grab all the information here: sfeirplaysnov2012.eventbrite.fr I&#8217;ll discuss the new stuff in WP8 and share feedback on my experience porting my existing WP7 app 2Day [...]]]></description>
				<content:encoded><![CDATA[<p>On November 28th I be speaking at an event organized by my very good friend Aline. SFEIRPlays is a free event opened to anyone (free registration is mandatory thought). You can grab all the information here: <a href="http://sfeirplaysnov2012.eventbrite.fr">sfeirplaysnov2012.eventbrite.fr</a></p>
<p><strong>I&#8217;ll discuss the new stuff in WP8 and share feedback on my experience porting my existing WP7 app <a href="http://www.2day-app.com">2Day</a> to both Windows Phone 8 and Windows 8.</strong></p>
<p>I&#8217;ll also bring a nice Nokia Lumia 920 so that you guys can try the device during the evening !</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/11/Lumia920-white.jpg" rel="lightbox[1400]"><img class="alignnone size-medium wp-image-1402" title="Lumia920-white" src="http://www.japf.fr/wp-content/uploads/2012/11/Lumia920-white-286x300.jpg" alt="" width="286" height="300" /></a></p>
<p>Hope to see you there <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2012/11/meet-me-at-sfeirplays-paris-2811-talking-wp8/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Welcome Windows Phone 8.0 SDK</title>
		<link>http://www.japf.fr/2012/10/welcome-windows-phone-8-0-sdk/</link>
		<comments>http://www.japf.fr/2012/10/welcome-windows-phone-8-0-sdk/#comments</comments>
		<pubDate>Tue, 30 Oct 2012 17:47:26 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[wp7]]></category>
		<category><![CDATA[wp8]]></category>
		<category><![CDATA[wpdev]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1281</guid>
		<description><![CDATA[It has been a long time since my last blog post, but today is an important day for any Windows Phone developers: the 8.0 SDK is now available. Because I&#8217;m a lucky guy I had the chance to be part of the selected developers who got an early access to the SDK. Today is finally [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.japf.fr/wp-content/uploads/2012/08/windowsphone8logo.jpg" rel="lightbox[1281]"><img class="alignnone  wp-image-1284" title="windowsphone8logo" src="http://www.japf.fr/wp-content/uploads/2012/08/windowsphone8logo.jpg" alt="" width="560" height="82" /></a></p>
<p>It has been a long time since my last blog post, but today is an important day for any Windows Phone developers: <strong>the 8.0 SDK is now <a href="http://www.microsoft.com/en-us/download/details.aspx?id=35471">available</a></strong>. Because I&#8217;m a lucky guy I had the chance to be part of the selected developers who got an early access to the SDK. Today is finally the day where I can publicly share all the goodness of the new version with you <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>You can grab the SDK <a href="http://www.microsoft.com/en-us/download/details.aspx?id=35471">here</a>. An ISO link is also available using <a href="http://go.microsoft.com/fwlink/?LinkID=257234&amp;clcid=0x409">this link</a>. Please note a new website is also available for design resources at: <a href="https://dev.windowsphone.com/en-us/design#">https://dev.windowsphone.com/en-us/design</a></p>
<p>In the next couple of days I will share a set of articles about this new SDK. In this first post, I will showcase the changes of the SDK itself.</p>
<p><strong>Requirements</strong></p>
<p>The requirements for running the 8.0 SDK are the following:</p>
<ul>
<li>Windows 8 x64</li>
<li>Visual Studio 2012 RTM</li>
<li><strong>To use the emulator:</strong> An Hyper-V capable machine (your CPU must support <a href="http://en.wikipedia.org/wiki/SLAT-enabled_processors">SLAT</a> or Second Level Address Translation)</li>
</ul>
<div>You can very quickly check if your hardware is able to run Hyper-V by trying to activate it from Windows 8. Do to so:</div>
<div>
<ul>
<li>press the Windows key</li>
<li>type &#8220;Turn windows features&#8221;</li>
<li>choose &#8220;Turn windows features on/off&#8221; in the Parameters section</li>
<li>see if you can check &#8220;Hyper-V / Hyper-V platform&#8221;</li>
</ul>
<div>You can also check-out <a href="http://www.zdnet.com/blog/bott/does-your-pc-have-what-it-takes-to-run-windows-8s-hyper-v/4254">this article</a> on <a href="http://www.zdnet.com">ZDNet</a> for a more complete overview of the requirements to run Hyper-V.</div>
</div>
<div></div>
<div><strong>Installation</strong></div>
<div></div>
<div>The installation is very straightforward as soon as you meet the requirements. Note that the installer UI is nice and similar to the new one available in Visual Studio 2012:</div>
<div></div>
<div><a href="http://www.japf.fr/wp-content/uploads/2012/08/Installer.png" rel="lightbox[1281]"><img class="alignnone size-medium wp-image-1306" title="Installer" src="http://www.japf.fr/wp-content/uploads/2012/08/Installer-263x300.png" alt="" width="263" height="300" /></a></div>
<div></div>
<div>The installation of the SDK is available at the following path: C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0</div>
<p><strong>Emulator</strong></p>
<p>Because the emulator now runs on top of Hyper-V, and is based on a Windows 8 kernel, the image file is actually a <a href="http://en.wikipedia.org/wiki/VHD_(file_format)">VHD</a> file !</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/08/VHDFiles.png" rel="lightbox[1281]"><img class="alignnone size-full wp-image-1312" title="VHDFiles" src="http://www.japf.fr/wp-content/uploads/2012/08/VHDFiles.png" alt="" width="734" height="153" /></a></p>
<p>And because a Windows 8 is now able to mount image-disk file without any additional software, you can just double click it to browse the content of the Windows Phone 8 file system. Of course unless you&#8217;re a some kind of hacker you want to deep dive into the core of the OS, this might not be very useful to you <img src='http://www.japf.fr/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/08/VHDInside.png" rel="lightbox[1281]"><img class="alignnone size-medium wp-image-1315" title="VHDInside" src="http://www.japf.fr/wp-content/uploads/2012/08/VHDInside-300x199.png" alt="" width="300" height="199" /></a></p>
<p>Another fun thing, because the emulator is using Hyper-V and because the images of the WP8 are in a VHD file, you can just create a new virtual computer in Hyper-V and set this VHD file as a hard drive to boot the WP8 right from Hyper-V:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/08/HyperV1.png" rel="lightbox[1281]"><img class="alignnone size-medium wp-image-1314" title="HyperV" src="http://www.japf.fr/wp-content/uploads/2012/08/HyperV1-300x188.png" alt="" width="300" height="188" /></a></p>
<p>Actually, despite many changes under the hood, the emulator will look very familiar to any WP7 developer. Without any doubt the most visible change will be the new start screen:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/08/Emulator.png" rel="lightbox[1281]"><img class="alignnone size-medium wp-image-1311" title="Emulator" src="http://www.japf.fr/wp-content/uploads/2012/08/Emulator-177x300.png" alt="" width="177" height="300" /></a></p>
<p>Note that we have the same tooling added with the release of Mango (accelerometer &amp; location simulators + snapshot tool):</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/08/EmulatorPlusTools.png" rel="lightbox[1281]"><img class="alignnone size-medium wp-image-1310" title="EmulatorPlusTools" src="http://www.japf.fr/wp-content/uploads/2012/08/EmulatorPlusTools-300x186.png" alt="" width="300" height="186" /></a></p>
<p>However, please note that the emulator no longer supports HW accelerated graphics. That means you will probably have less good performance (ie. framerates) that you did on the previous emulator. Make sure to run your test on a real device to make sure performance are good.</p>
<p><strong>Visual Studio 2012 integration</strong></p>
<p>The 8.0 SDK adds new project templates:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/08/NewProject.png" rel="lightbox[1281]"><img class="alignnone size-medium wp-image-1307" title="NewProject" src="http://www.japf.fr/wp-content/uploads/2012/08/NewProject-300x207.png" alt="" width="300" height="207" /></a></p>
<ul>
<li>In the C# section
<ul>
<li>Windows Phone Direct 3D XAML application: &#8220;A project for creating Windows Phone managed application with native interop&#8221;</li>
</ul>
</li>
<li>In the C++ section
<ul>
<li>Windows Phone Direct3D App: &#8220;A project for creating a Windows Phone application that uses Direct3D&#8221;</li>
<li>Windows Phone Runtime Component: &#8220;A project for creating a Windows Phone Runtime component for a Windows Phone app&#8221;</li>
<li>Empty Dynamic Link Library: &#8220;A project for creating a native dynamic-link library for a Windows Phone app&#8221;</li>
<li>Empty Static Link Library: &#8220;A project for creating a native static library for a Windows Phone app&#8221;</li>
</ul>
</li>
</ul>
<div>Note that you can still targets the 7.1 OS when you creates your application in VS12:</div>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/08/PlatformVersion.png" rel="lightbox[1281]"><img class="alignnone size-medium wp-image-1308" title="PlatformVersion" src="http://www.japf.fr/wp-content/uploads/2012/08/PlatformVersion-300x138.png" alt="" width="300" height="138" /></a></p>
<p>If like me you&#8217;re a C# Async fan you will need the Async Pack for Visual Studio 2012 in order to enable async support in your 7.1 projects. You can very easily add this supports using a NuGet Package (Microsoft.Bcl.Async). See this post for more details: <a href="http://blogs.msdn.com/b/bclteam/archive/2012/10/22/using-async-await-without-net-framework-4-5.aspx">http://blogs.msdn.com/b/bclteam/archive/2012/10/22/using-async-await-without-net-framework-4-5.aspx</a></p>
<p><strong>Support for new screen resolutions</strong></p>
<p>Windows Phone 8.0 devices will come with various flavors regarding screen resolutions. You might remember that the first initial announcements of Windows Phone 7.0 also stated 2 resolutions but we saw only 800&#215;480 devices so far. This is going to change in 8.0 and the emulator now supports this:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/08/EmulatorResolutions.png" rel="lightbox[1281]"><img class="alignnone size-medium wp-image-1309" title="EmulatorResolutions" src="http://www.japf.fr/wp-content/uploads/2012/08/EmulatorResolutions-300x165.png" alt="" width="300" height="165" /></a></p>
<p><strong>Blend for Visual Studio</strong></p>
<p>The SDK comes with a version of Blend that can be used with Windows Phone 8 projects:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/10/BlendForVisualStudio.png" rel="lightbox[1281]"><img class="alignnone size-medium wp-image-1390" title="BlendForVisualStudio" src="http://www.japf.fr/wp-content/uploads/2012/10/BlendForVisualStudio-266x300.png" alt="" width="266" height="300" /></a></p>
<p>You will find templates for XAML-bases projects:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/10/BlendForVisualStudio-Welcome.png" rel="lightbox[1281]"><img class="alignnone size-medium wp-image-1392" title="BlendForVisualStudio-Welcome" src="http://www.japf.fr/wp-content/uploads/2012/10/BlendForVisualStudio-Welcome-300x234.png" alt="" width="300" height="234" /></a></p>
<p>And support for new screen resolutions:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/10/BlendForVisualStudio-ScreenResolutions.png" rel="lightbox[1281]"><img class="alignnone size-full wp-image-1391" title="BlendForVisualStudio-ScreenResolutions" src="http://www.japf.fr/wp-content/uploads/2012/10/BlendForVisualStudio-ScreenResolutions.png" alt="" width="276" height="265" /></a></p>
<p><strong>Conclusion</strong></p>
<p>This is just the beginning ! They are a tons of new opportunities with this release of Windows Phone ! In the next blog post, I will highlight various new APIs available to the developers.</p>
<p>I&#8217;m glad to see the ability to write app using native code. Funnily enough after spending 4 years doing only C# in my professional job I moved a couple of weeks ago to a mixed C#/C++ world &#8211; and I&#8217;m liking it so far <img src='http://www.japf.fr/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Finally, I&#8217;m looking forward improving the <a href="http://www.2day-app.com">2Day app</a> I have in the marketplace and finding ideas for new apps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2012/10/welcome-windows-phone-8-0-sdk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fun with ILDASM and ILASM: tweaking the code of an existing library</title>
		<link>http://www.japf.fr/2012/10/fun-with-ildasm-and-ilasm-tweaking-the-code-of-an-existing-library/</link>
		<comments>http://www.japf.fr/2012/10/fun-with-ildasm-and-ilasm-tweaking-the-code-of-an-existing-library/#comments</comments>
		<pubDate>Mon, 22 Oct 2012 17:34:56 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[il]]></category>
		<category><![CDATA[reverse]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1380</guid>
		<description><![CDATA[Today I decided it was the appropriate time to upgrade my work PC from Windows 7 to Windows 8. I&#8217;m already using Windows 8 on my personal PC as well as on my //BUILD/ Slate. Re-installing an OS is never really exciting but this time I faced an interesting challenge&#8230; In this short blog post [...]]]></description>
				<content:encoded><![CDATA[<p>Today I decided it was the appropriate time to upgrade my work PC from Windows 7 to Windows 8. I&#8217;m already using Windows 8 on my personal PC as well as on my //BUILD/ Slate. Re-installing an OS is never really exciting but this time I faced an interesting challenge&#8230; In this short blog post I share this story !</p>
<p><strong>Check-list</strong></p>
<p>The PC I&#8217;m using at work is a HP Elitebook8560P laptop. I had no doubt Windows8 would work like a charm on it, so I started by writing up the list of major tools I need:</p>
<ul>
<li>VS2005 (yes, the 2005 version &#8211; that&#8217;s a long story&#8230; it&#8217;s for C++ work)</li>
<li>VS2010 + SP1</li>
<li>Office 2010</li>
<li>Office 2013</li>
</ul>
<p>I also would like to install VS2012 but one of the .Net component I&#8217;m using in the large WPF app I&#8217;m currently working on has a bug with .Net 4.5. If I install VS2012 .Net4.5 will be installed to and prevent the execution of my app. This was at least the behavior I found out on Windows7 while taking a look at VS12.</p>
<p>The team in charge of the component (which are co-workers btw) are aware of the issue and already fixed it. We didn&#8217;t integrate their last version yet however.</p>
<p><strong>Installation</strong></p>
<p>This is the part you press and button, grab a cup of cofee and get back in front of the screen to press another button. Nothing really interesting here&#8230;</p>
<p><strong>Fun-time</strong></p>
<p>Ok, everything is installed. Time to check I can run my app. Arrrrg !!! Crash !!!</p>
<p>I took me a few seconds to figure out that Windows8 comes with .Net 4.5 pre-installed. Well, that&#8217;s a problem, at least for me. I reviewed the option I had:</p>
<ul>
<li>go back to Windows 7 and reinstall everything again. I didn&#8217;t have the time for that.</li>
<li>remove .Net 4.5 from my laptop. This is actually not possible since .Net 4.5 comes with Windows8.</li>
<li>come at work very early monday morning and try to grab the new version of the buggy component. This is a very bad option since I&#8217;m in the middle of an important delivery&#8230;</li>
</ul>
<div>Then I realize I knew exactly what was going wrong in the component that lead to the crash. What about disassembling the code to IL (Intermediate Language), recompile it and use this hacked DLL ? This is what I did, and it worked very well <img src='http://www.japf.fr/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </div>
<p><strong>Why a crash ?</strong></p>
<p>Just to share the context, the buggy component is a WPF control. It contains UI virtualization stuff. One of the method contains a &#8220;throw NotImplementedException&#8221;. This method is called when a particular Dispose() method is called. This method was NEVER called prior to .Net 4.5 hiding the problem. The new version of the .Net framework calls the Dispose method properly&#8230; and then throws the exception <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Introducing ILDASM and its friend ILASM</strong></p>
<p><strong></strong><a href="http://msdn.microsoft.com/en-us/library/f7dy01k1(v=vs.80).aspx">ILDASM</a> is the MSIL disassembler provider with Visual Studio. It comes with a very basic UI but you can also use it a command line and dump the content of a .Net binary to a file (containing the IL). So I fired up the VS2010 command prompt and typed:</p>
<pre><strong>ildasm.exe Company.BuggyComponent.dll /output Company.BuggyComponent.il</strong></pre>
<p>I then opened the file using a basic text editor, navigate to the method which contains this code:</p>
<pre>.method public hidebysig newslot virtual final 
 instance void Clear() cil managed
{
 // Code size 6 (0x6)
 .maxstack 8
 IL_0000: newobj instance void [mscorlib]System.NotSupportedException::.ctor()
 IL_0005: throw
} // end of method VirtualizingCollectionSelector`1::Clear</pre>
<p>I changed it to:</p>
<pre>.method public hidebysig newslot virtual final</pre>
<pre> instance void Clear() cil managed
{
 // Code size 1 (0x1)
 .maxstack 8
 IL_0000: ret
} // end of method VirtualizingCollectionSelector`1::Clear</pre>
<p>Then I rebuilt a new DLL using <a href="http://msdn.microsoft.com/en-us/library/496e4ekx%28v=VS.80%29.aspx">ILASM</a>. The tool is able to create an executable or an assembly from IL code in a text fix. So I simply typed:</p>
<pre>ilasm Company.BuggyComponent.il /key=company.snk /output=CompanyBuggyComponent.dll</pre>
<p>I dropped the newly created assembly in the bin directory, and boom, it&#8217;s working again. Of course this is a temporary solution but I had fun coming to it <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>PS: the 3 screens running Windows8 at home: personal workstation, slate and work laptop</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/10/WP_000692.jpg" rel="lightbox[1380]"><img class="alignnone size-medium wp-image-1381" title="WP_000692" src="http://www.japf.fr/wp-content/uploads/2012/10/WP_000692-300x224.jpg" alt="" width="300" height="224" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2012/10/fun-with-ildasm-and-ilasm-tweaking-the-code-of-an-existing-library/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
