<?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>Mélange &#187; General</title>
	<atom:link href="http://pradeepc.net/blog/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://pradeepc.net/blog</link>
	<description>the colors of my life</description>
	<lastBuildDate>Wed, 11 Jan 2012 02:43:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>What I miss about C#</title>
		<link>http://pradeepc.net/blog/2011/11/07/what-i-miss-about-c/</link>
		<comments>http://pradeepc.net/blog/2011/11/07/what-i-miss-about-c/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 19:03:02 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/?p=455</guid>
		<description><![CDATA[It has been a month or so since I started programming in C++. To be frank it is not the monster that I thought it would be and it wasn&#8217;t that hard to move to C++ from C#. Granted I &#8230; <a href="http://pradeepc.net/blog/2011/11/07/what-i-miss-about-c/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It has been a month or so since I started programming in C++. To be frank it is not the monster that I thought it would be and it wasn&#8217;t that hard to move to C++ from C#. Granted I haven&#8217;t faced any of the notorious and nasty bugs that is difficult to debug in native code but I still think C++ isn&#8217;t as hard as I thought it would be (touch wood).</p>
<p>That being said I do miss a few things that I was used to in C# and .NET. Here are the top 3:</p>
<ol>
<li>Refactoring tools</li>
<li>Garbage collection</li>
<li>A good mocking framework for unit testing</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2011/11/07/what-i-miss-about-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Welcome 2011</title>
		<link>http://pradeepc.net/blog/2011/01/08/welcome-2011/</link>
		<comments>http://pradeepc.net/blog/2011/01/08/welcome-2011/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 06:57:07 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/?p=443</guid>
		<description><![CDATA[I have had quite a few resolutions for 2010. Now I hold my head high and tell you all &#8211; I didn&#8217;t do even one of them While that speaks volumes about my nature, I wouldn&#8217;t want you to think &#8230; <a href="http://pradeepc.net/blog/2011/01/08/welcome-2011/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have had quite a few resolutions for 2010. Now I hold my head high and tell you all &#8211; I didn&#8217;t do even one of them <img src='http://pradeepc.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>While that speaks volumes about my nature, I wouldn&#8217;t want you to think I am quitter. I have more resolutions for this year.</p>
<ul>
<li>I will reduce my weight by 15 lbs. I weigh 185 lbs now, so by Dec 2011 I expect to be 170 lbs. I haven&#8217;t been 170 lbs since some time in 2002. Now I expect to be back at that weight by 2012.</li>
<li>I will reduce my cholesterol to normal values. Now I am grossly over the normal values (total cholesterol = 300)</li>
<li>I will greatly increase my knowledge on algorithms and data-structures. This is a vague one. But that&#8217;s OK. Any progress in this direction is good for me.</li>
<li>I will study discrete mathematics. This is also quite vague but my intention is to be a little less clueless than I am now.</li>
</ul>
<p>That is it friends. Just 4 things. Let us see how that goes.</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2011/01/08/welcome-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using TFS (TeamBuild) to build Setup projects in Visual Studio</title>
		<link>http://pradeepc.net/blog/2009/12/18/using-tfs-teambuild-to-build-setup-projects-in-visual-studio/</link>
		<comments>http://pradeepc.net/blog/2009/12/18/using-tfs-teambuild-to-build-setup-projects-in-visual-studio/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 00:57:27 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/18/using-tfs-teambuild-to-build-setup-projects-in-visual-studio/</guid>
		<description><![CDATA[If you took the shortcut of a Visual Studio Setup project (as opposed to using Wix) then you must have faced the same problem that I did, viz., not being able to create the MSI as part of your TFS &#8230; <a href="http://pradeepc.net/blog/2009/12/18/using-tfs-teambuild-to-build-setup-projects-in-visual-studio/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you took the shortcut of a Visual Studio Setup project (as opposed to using Wix) then you must have faced the same problem that I did, viz., not being able to create the MSI as part of your TFS nightly builds which hands over the bits to the test team. The problem here is that the vdproj files of the setup projects is in a format that MSBuild (and TeamBuild) does not understand. But we know that Visual Studio can build this project. So I tried to see if I can use devenv.exe to build the project. I tried devenv.exe /? on the command prompt and found that it indeed takes a build switch. So I tried this devenv.exe MySetup.vdproj /build</p>
<p>That did not succeed. The following error message was spit out:</p>
<blockquote><p>Microsoft (R) Visual Studio Version 9.0.30729.1.      <br />Copyright (C) Microsoft Corp. All rights reserved.       <br />&#8212;&#8212; Starting pre-build validation for project &#8216;MySetup&#8217; &#8212;&#8212;       <br />ERROR: Cannot find outputs of project output group &#8216;(unable to determine name)&#8217;.&#160; Either the group, its configuration, or its project may have been removed from the solution.       <br />ERROR: Cannot find outputs of project output group &#8216;(unable to determine name)&#8217;.&#160; Either the group, its configuration, or its project may have been removed from the solution.       <br />&#8212;&#8212; Pre-build validation for project &#8216;MySetup&#8217; completed &#8212;&#8212;       <br />&#8212;&#8212; Build started: Project: MySetup, Configuration: Debug &#8212;&#8212;       <br />========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========</p>
</blockquote>
<p>I then decided to run it against the solution file devenv.exe MySolution.sln /Build</p>
<p>That did the trick. The setup files were created in MySolution/MySetup/Debug/ folder.</p>
<p>So I needed to integrate this into the build script. Using devenv.exe means this build machine needs to have Visual Studio installed on it. We already had it, so I was in luck. In some teams they might not allowed the build machine to have Visual Studio.&#160; </p>
<p>I added the path to devenv.exe to the system path. Screen shot below should show you how to do that.</p>
<p><a href="http://pradeepc.net/blog/wp-content/uploads/2009/12/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://pradeepc.net/blog/wp-content/uploads/2009/12/image_thumb.png" width="939" height="546" /></a> </p>
<p>As a first attempt I added the following code to the AfterDropBuild target.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">Target </span><span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">AfterDropBuild</span>&quot;<span style="color: blue">&gt;   </span><span style="color: blue">
    &lt;</span><span style="color: #a31515">Exec </span><span style="color: red">Command</span><span style="color: blue">=</span>&quot;<span style="color: blue">devenv.exe $(SolutionRoot)/MySolution.sln /Build</span>&quot;<span style="color: blue">/&gt;
    &lt;</span><span style="color: #a31515">ItemGroup</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">SetupFiles </span><span style="color: red">Include</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)/MySetup/Release/MySetup.msi</span>&quot; <span style="color: blue">/&gt;
      &lt;</span><span style="color: #a31515">SetupFiles </span><span style="color: red">Include</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)/MySetup/Release/Setup.exe</span>&quot; <span style="color: blue">/&gt;
    &lt;/</span><span style="color: #a31515">ItemGroup</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">Copy </span><span style="color: red">SourceFiles</span><span style="color: blue">=</span>&quot;<span style="color: blue">@(SetupFiles)</span>&quot; <span style="color: red">DestinationFolder</span><span style="color: blue">=</span>&quot;<span style="color: blue"><a href="file://\\Build-Machine\Build_Drop_Folders\MyProjectMSI\$(BuildNumber">C:\Temp\MS</a></span>I&quot; <span style="color: blue">/&gt;
</span><span style="color: blue">  &lt;/</span><span style="color: #a31515">Target</span><span style="color: blue">&gt;</span></pre>
<p>This attempt failed. The error message was not helpful. So I logged into the build machine and tried the same command from command prompt and nothing happened ! So changed the current directory to the location of the sln file and then ran the command again and it worked. So it seems that devenv needs only the name of the sln file (not the full path to it) and the current working directory needs to be the directory when the sln file resides. </p>
<p>So my second attempt:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">Target </span><span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">AfterDropBuild</span>&quot;<span style="color: blue">&gt;   </span><span style="color: blue">
    &lt;</span><span style="color: #a31515">Exec </span><span style="color: red">Command</span><span style="color: blue">=</span>&quot;<span style="color: blue">devenv.exe MySolution.sln /Build</span>&quot; <span style="color: red">WorkingDirectory</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)</span>&quot;<span style="color: blue">/&gt;
    &lt;</span><span style="color: #a31515">ItemGroup</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">SetupFiles </span><span style="color: red">Include</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)/MySetup/Release/MySetup.msi</span>&quot; <span style="color: blue">/&gt;
      &lt;</span><span style="color: #a31515">SetupFiles </span><span style="color: red">Include</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)/MySetup/Release/Setup.exe</span>&quot; <span style="color: blue">/&gt;
    &lt;/</span><span style="color: #a31515">ItemGroup</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">Copy </span><span style="color: red">SourceFiles</span><span style="color: blue">=</span>&quot;<span style="color: blue">@(SetupFiles)</span>&quot; <span style="color: red">DestinationFolder</span><span style="color: blue">=</span>&quot;<span style="color: blue"><a href="file://\\Build-Machine\Build_Drop_Folders\MyProjectMSI\$(BuildNumber">C:\Temp\MSI</a></span>&quot; <span style="color: blue">/&gt;</span><span style="color: blue">
  &lt;/</span><span style="color: #a31515">Target</span><span style="color: blue">&gt;</span></pre>
<p>That worked ! Well not fully, but the Exec task worked but the Copy task failed. I found the reason for that was the files were getting created in the Debug folder and not the Release folder. In order to force a Release build I had to pass additional info to devenv. So I changed the script as shown below and I could see the bits were getting copied correctly.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">Target </span><span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">AfterDropBuild</span>&quot;<span style="color: blue">&gt;</span><span style="color: blue">
    &lt;</span><span style="color: #a31515">Exec </span><span style="color: red">Command</span><span style="color: blue">=</span>&quot;<span style="color: blue">devenv.exe MySolution.sln /Build </span><span style="color: red">&amp;quot;</span><span style="color: blue">Release|Any CPU</span><span style="color: red">&amp;quot;</span>&quot; <span style="color: red">WorkingDirectory</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)</span>&quot;<span style="color: blue">/&gt;
    &lt;</span><span style="color: #a31515">ItemGroup</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">SetupFiles </span><span style="color: red">Include</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)/MySetup/Release/MySetup.msi</span>&quot; <span style="color: blue">/&gt;
      &lt;</span><span style="color: #a31515">SetupFiles </span><span style="color: red">Include</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)/MySetup/Release/Setup.exe</span>&quot; <span style="color: blue">/&gt;
    &lt;/</span><span style="color: #a31515">ItemGroup</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">Copy </span><span style="color: red">SourceFiles</span><span style="color: blue">=</span>&quot;<span style="color: blue">@(SetupFiles)</span>&quot; <span style="color: red">DestinationFolder</span><span style="color: blue">=</span>&quot;<span style="color: blue"><a href="file://\\Build-Machine\Build_Drop_Folders\MyProjectMSI\$(BuildNumber">C:\Temp\MSI</a></span>&quot; <span style="color: blue">/&gt;
</span><span style="color: blue">  &lt;/</span><span style="color: #a31515">Target</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Here is my final version for copying it to a remote drop location.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">Target </span><span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">AfterDropBuild</span>&quot;<span style="color: blue">&gt;   </span><span style="color: blue">
    &lt;</span><span style="color: #a31515">Exec </span><span style="color: red">Command</span><span style="color: blue">=</span>&quot;<span style="color: blue">devenv.exe MySolution.sln /Build </span><span style="color: red">&amp;quot;</span><span style="color: blue">Release|Any CPU</span><span style="color: red">&amp;quot;</span>&quot; <span style="color: red">WorkingDirectory</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)</span>&quot;<span style="color: blue">/&gt;
    &lt;</span><span style="color: #a31515">ItemGroup</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">SetupFiles </span><span style="color: red">Include</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)/MySetup/Release/MySetup.msi</span>&quot; <span style="color: blue">/&gt;
      &lt;</span><span style="color: #a31515">SetupFiles </span><span style="color: red">Include</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(SolutionRoot)/MySetup/Release/Setup.exe</span>&quot; <span style="color: blue">/&gt;
    &lt;/</span><span style="color: #a31515">ItemGroup</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">Copy </span><span style="color: red">SourceFiles</span><span style="color: blue">=</span>&quot;<span style="color: blue">@(SetupFiles)</span>&quot; <span style="color: red">DestinationFolder</span><span style="color: blue">=</span>&quot;<span style="color: blue"><a href="file://\\Build-Machine\Build_Drop_Folders\MyProjectMSI\$(BuildNumber">\\Build-Machine\Build_Drop_Folders\MyProjectMSI\$(BuildNumber</a>)</span>&quot; <span style="color: blue">/&gt;
    &lt;</span><span style="color: #a31515">Copy </span><span style="color: red">SourceFiles</span><span style="color: blue">=</span>&quot;<span style="color: blue">@(SetupFiles)</span>&quot; <span style="color: red">DestinationFolder</span><span style="color: blue">=</span>&quot;<span style="color: blue"><span style="color: blue"><a href="file://\\Build-Machine\Build_Drop_Folders\MyProjectMSI\Latest_MSI">\\Build-Machine\Build_Drop_Folders\MyProjectMSI</span>\Latest_MSI</a></span>&quot; <span style="color: blue">/&gt;
  &lt;/</span><span style="color: #a31515">Target</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Note: Here $(SolutionRoot) is the path you have given while creating the build definition. You can see it by editing the build definition.</p>
<p><a href="http://pradeepc.net/blog/wp-content/uploads/2009/12/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://pradeepc.net/blog/wp-content/uploads/2009/12/image_thumb1.png" width="939" height="553" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/12/18/using-tfs-teambuild-to-build-setup-projects-in-visual-studio/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Plans for 2010</title>
		<link>http://pradeepc.net/blog/2009/12/16/plans-for-2010/</link>
		<comments>http://pradeepc.net/blog/2009/12/16/plans-for-2010/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 08:38:01 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/16/plans-for-2010/</guid>
		<description><![CDATA[I don’t usually make new year resolutions. It is not because I am perfect and doesn’t need to make any changes, but it is because of my lazy nature. I have made up my mind several times in the past &#8230; <a href="http://pradeepc.net/blog/2009/12/16/plans-for-2010/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I don’t usually make new year resolutions. It is not because I am perfect and doesn’t need to make any changes, but it is because of my lazy nature. I have made up my mind several times in the past about achieving this and achieving that, but usually I don’t ever bring myself to completing my projects. </p>
<p>So why this year ?</p>
<p>I don’t know, but I think it would be a good thing to try. Like a new cuisine or a new hair style,&#160; sometimes a change is nice to have &#8211; they add spice to life. So I am going to give new year resolutions a try this year. </p>
<p>So what is different this time ?</p>
<p>This time I am publicly disclosing the things I want to achieve, the projects I want to complete. I remember having read somewhere that it would be good idea to make our aspirations public. This would help motivate us to complete our projects.</p>
<p>As of now, I have 3 things in mind for 2010.</p>
<ul>
<li>I have decided to write a series of blog posts on the common software <a href="http://en.wikipedia.org/wiki/Design_pattern" target="_blank">design patterns</a> made popular by the <a href="http://en.wikipedia.org/wiki/Design_Patterns_%28book%29" target="_blank">GoF</a>. Why design patterns? Frankly, I don’t have a very clear reason. I know it is not the hottest topic to blog about, but it is definitely a useful one. Especially for me. I have been reading about design patterns, and occasionally putting to practice, since some time in 2003 when <a href="http://binil.wordpress.com/" target="_blank">Binil</a> gave me <em>The</em> <a href="http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612" target="_blank">Design Patterns</a> book. Since then, I have read a few more books on the topic. But I don’t claim to be master on the topic. Actually far from it, my understanding of many of the “advanced” patterns are still vague. Haven’t we all heard the age old adage &#8211; “the best way to learn something is to teach it.”. So I am going to write about them, which will help me understand them better and if someone is able to glean something from my posts, it will be a pleasant bonus. This would also be a good exercise in writing and keep the blog rolling.&#160;&#160; </li>
<li>Read some books. Not the kind of glancing over that I do nowadays. A thorough reading. Understanding the concepts and making it part of myself. This is pretty ambitious. As of now I have two candidates in my mind for this project. The first book is <a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html#%_toc_start" target="_blank">Structure and Interpretation of Computer Programs</a> (I have had this book for 3 years now) and the second one is <a href="http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215" target="_blank">Domain Driven Design</a> (been in my shelf for a little over 2 years). These are not easy books to read. But they are important books to have read for any computer programmer. As I mentioned before this is quite an ambitious target.&#160; </li>
<li>Visit some places. I have been in the US of A for about 3.5 years now. But I haven’t seen many of the good places here. Even in Washington state, there are so many good places to see. Now that I am married I have a travel companion too <img src='http://pradeepc.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </li>
</ul>
<p>I don’t know how much of this I can accomplish (as with all other things in the future). But I think it is worth a try.</p>
<p>Wish me luck. </p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/12/16/plans-for-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>LocalMessageSender with strongly typed objects</title>
		<link>http://pradeepc.net/blog/2009/11/25/localmessagesender-with-strongly-typed-objects/</link>
		<comments>http://pradeepc.net/blog/2009/11/25/localmessagesender-with-strongly-typed-objects/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 23:48:54 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/11/25/localmessagesender-with-strongly-typed-objects/</guid>
		<description><![CDATA[If you need to have two Silverlight apps talking to each other, you would be using the LocalMessageSender and LocalMessageReceiver classes from the System.Windows.Messaging namespace. The LocalMessageSender class will only allow you to send string messages. So if you are &#8230; <a href="http://pradeepc.net/blog/2009/11/25/localmessagesender-with-strongly-typed-objects/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you need to have two Silverlight apps talking to each other, you would be using the LocalMessageSender and LocalMessageReceiver classes from the System.Windows.Messaging namespace. The LocalMessageSender class will only allow you to send string messages. So if you are looking to send strongly typed objects using the LocalMessageSender you will have to serialize the object and then deserialize it at the other end. I created a class which will do this work for you. I decided to use JSON as the serialization format because it is much more lightweight than Xml.</p>
<pre class="code"><span style="color: blue">using </span>System.IO;
<span style="color: blue">using </span>System.Runtime.Serialization.Json;
<span style="color: blue">using </span>System.Text;

<span style="color: blue">namespace </span>Common
{
    <span style="color: blue">public class </span><span style="color: #2b91af">JsonSerializer</span>&lt;T&gt;
    {
        <span style="color: blue">public static string </span>Serialize(T objectToSerialize)
        {
            <span style="color: blue">using </span>(<span style="color: #2b91af">MemoryStream </span>stream = <span style="color: blue">new </span><span style="color: #2b91af">MemoryStream</span>())
            {
                <span style="color: #2b91af">DataContractJsonSerializer </span>serializer = <span style="color: blue">new </span><span style="color: #2b91af">DataContractJsonSerializer</span>(<span style="color: blue">typeof</span>(T));
                serializer.WriteObject(stream, objectToSerialize);
                stream.Position = <span style="color: brown">0</span>;

                <span style="color: blue">using </span>(<span style="color: #2b91af">StreamReader </span>reader = <span style="color: blue">new </span><span style="color: #2b91af">StreamReader</span>(stream))
                {
                    <span style="color: blue">return </span>reader.ReadToEnd();
                }
            }
        }

        <span style="color: blue">public static </span>T Deserialize(<span style="color: blue">string </span>jsonString)
        {
            <span style="color: blue">using </span>(<span style="color: #2b91af">MemoryStream </span>stream = <span style="color: blue">new </span><span style="color: #2b91af">MemoryStream</span>(<span style="color: #2b91af">Encoding</span>.Unicode.GetBytes(jsonString)))
            {
                <span style="color: #2b91af">DataContractJsonSerializer </span>serializer = <span style="color: blue">new </span><span style="color: #2b91af">DataContractJsonSerializer</span>(<span style="color: blue">typeof</span>(T));
                <span style="color: blue">return </span>(T)serializer.ReadObject(stream);
            }
        }
    }
}</pre>
<p>You can use this class like this</p>
<pre class="code"><span style="color: blue">string </span>serializedMsg = <span style="color: #2b91af">JsonSerializer</span>&lt;<span style="color: #2b91af">SimpleMessage</span>&gt;.Serialize(msg); </pre>
<pre class="code"><span style="color: #2b91af">SimpleMessage </span>msg = <span style="color: #2b91af">JsonSerializer</span>&lt;<span style="color: #2b91af">SimpleMessage</span>&gt;.Deserialize(serializedMsg);</pre>
<p>To give credit where it is due, I stole most of this code from here &#8211; <a title="http://www.silverlightshow.net/items/JSON-serialization-and-deserialization-in-Silverlight.aspx" href="http://www.silverlightshow.net/items/JSON-serialization-and-deserialization-in-Silverlight.aspx">http://www.silverlightshow.net/items/JSON-serialization-and-deserialization-in-Silverlight.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/11/25/localmessagesender-with-strongly-typed-objects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>LocalMessageSender with retry capability</title>
		<link>http://pradeepc.net/blog/2009/11/25/localmessagesender-with-retry-capability/</link>
		<comments>http://pradeepc.net/blog/2009/11/25/localmessagesender-with-retry-capability/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 23:35:23 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/11/25/localmessagesender-with-retry-capability/</guid>
		<description><![CDATA[If you need to have two Silverlight apps talking to each other, you would be using the LocalMessageSender and LocalMessageReceiver classes from the System.Windows.Messaging namespace. The problem with the LocalMessageSender is that it might not be able to send message &#8230; <a href="http://pradeepc.net/blog/2009/11/25/localmessagesender-with-retry-capability/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you need to have two Silverlight apps talking to each other, you would be using the LocalMessageSender and LocalMessageReceiver classes from the System.Windows.Messaging namespace. The problem with the LocalMessageSender is that it might not be able to send message at the very first try. So you will have to write code which retries to send the message for an x number of times. Rather than duplicating this code all over the place, I decided to create a class which will do this for you.</p>
<pre class="code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Windows.Messaging;

<span style="color: blue">namespace </span>Common
{
    <span style="color: blue">public class </span><span style="color: #2b91af">RetryMessageSender
    </span>{
        <span style="color: blue">private readonly int </span>maxRetryCount;
        <span style="color: blue">private </span><span style="color: #2b91af">LocalMessageSender </span>messageSender;
        <span style="color: blue">private int </span>retryCount = <span style="color: brown">1</span>;

        <span style="color: blue">public event </span><span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">SendCompletedEventArgs</span>&gt; SendCompleted;

        <span style="color: blue">public </span>RetryMessageSender(<span style="color: #2b91af">LocalMessageSender </span>messageSender)
            : <span style="color: blue">this</span>(messageSender, <span style="color: brown">100 </span><span style="color: green">/*default value of max retries*/</span>)
        {
        }

        <span style="color: blue">public </span>RetryMessageSender(<span style="color: #2b91af">LocalMessageSender </span>messageSender, <span style="color: blue">int </span>maxRetries)
        {
            <span style="color: blue">this</span>.messageSender = messageSender;
            <span style="color: blue">this</span>.maxRetryCount = maxRetries;
            messageSender.SendCompleted += <span style="color: blue">new </span>System.<span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">SendCompletedEventArgs</span>&gt;(messageSender_SendCompleted);
        }

        <span style="color: blue">public void </span>SendMessage(<span style="color: blue">string </span>msg)
        {
            messageSender.SendAsync(msg);
        }

        <span style="color: blue">void </span>messageSender_SendCompleted(<span style="color: blue">object </span>sender, <span style="color: #2b91af">SendCompletedEventArgs </span>e)
        {
            <span style="color: blue">if </span>(e.Error != <span style="color: blue">null</span>)
            {
                <span style="color: blue">if </span>(retryCount &lt;= maxRetryCount)
                {
                    retryCount++;
                    SendMessage(e.Message);
                }
                <span style="color: blue">else
                </span>{
                    SendCompleted(sender, e);
                }
            }
            <span style="color: blue">else
            </span>{
                retryCount = <span style="color: brown">0</span>;
                SendCompleted(sender, e);
            }
        }
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Now you can use this class like this:</p>
<pre class="code"><span style="color: #2b91af">RetryMessageSender </span>msgSender = <span style="color: blue">new </span><span style="color: #2b91af">RetryMessageSender</span>(messageSender, <span style="color: brown">10</span>);
msgSender.SendCompleted += <span style="color: blue">new </span>System.<span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">SendCompletedEventArgs</span>&gt;(msgSender_SendCompleted);
msgSender.SendMessage(<span style="color: #a31515">&quot;hello&quot;</span>);</pre>
<pre class="code">In the SendCompleted event handler, you can check whether the message was sent successfully within the specified number of retries (10 in this case).</pre>
<blockquote>
<div align="left">
<pre class="code"><span style="color: blue">static void </span>msgSender_SendCompleted(<span style="color: blue">object </span>sender, <span style="color: #2b91af">SendCompletedEventArgs </span>e)
{
    <span style="color: blue">if </span>(e.Error != <span style="color: blue">null</span>)
    {
         <span style="color: blue">throw new </span>System.<span style="color: #2b91af">Exception</span>(<span style="color: #a31515">&quot;Unable to send message even after 10 retries&quot;</span>);
    }
}</pre>
</p></div>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/11/25/localmessagesender-with-retry-capability/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Coders at Work</title>
		<link>http://pradeepc.net/blog/2009/09/20/coders-at-work/</link>
		<comments>http://pradeepc.net/blog/2009/09/20/coders-at-work/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 17:12:18 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/?p=248</guid>
		<description><![CDATA[Coders at Work is a new book from Apress which follows the same format as Founders at Work which I reviewed here earlier. It is collection of interviews by Peter Seibel (yes, the same guy who wrote the excellent Practical &#8230; <a href="http://pradeepc.net/blog/2009/09/20/coders-at-work/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/Coders-at-Work-Peter-Seibel/dp/1430219483/" target="_blank">Coders at Work</a> is a new book from <a href="http://www.apress.com/" target="_blank">Apress</a> which follows the same format as <a href="http://www.amazon.com/Founders-Work-Stories-Startups-Problem-Solution/dp/1430210788/" target="_blank">Founders at Work</a> which I reviewed <a href="http://pradeepc.net/blog/?p=141" target="_blank">here</a> earlier. It is collection of interviews by <a href="http://gigamonkeys.com/" target="_blank">Peter Seibel</a> (yes, the same guy who wrote the excellent <a href="http://gigamonkeys.com/book/" target="_blank">Practical Common Lisp</a>) with some of the icons of software programming like Peter Norvig, Ken Thompson, Donald Knuth, Joshua Bloch, Douglas Crockford etc (the initial list consisted of 284 people and was narrowed down to 15).  Not surprisingly there is a lot of excitement around the book and is getting good reviews on Amazon. I hope to read it soon. I almost pre-ordered it from Amazon but since my Amazon Prime had expired I would have had to pay for shipping (since it is under the $25 limit) so I didnt complete the order. Unfortunately the discount has now decreased from 43% to 34%. Now I wonder whether I should buy it or get it from the library. Not that I mind shelling out $20 for a good book but my apartment is now full of books that I am trying to reduce the number of books that I buy. There is also a companion website for the book at <a href="http://www.codersatwork.com/" target="_blank">codersatwork.com.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/09/20/coders-at-work/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jolt Awards 2007 Finalists</title>
		<link>http://pradeepc.net/blog/2008/01/10/jolt-awards-2007-finalists/</link>
		<comments>http://pradeepc.net/blog/2008/01/10/jolt-awards-2007-finalists/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 18:27:32 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/?p=198</guid>
		<description><![CDATA[The books: General Books &#160; Beautiful Code Edited by Andy Oram and Greg Wilson O&#8217;Reilly Geekonomics: The Real Cost of Insecure Software by David Rice Addison-Wesley Professional Manage It!: Your Guide to Modern Pragmatic Project Management by Johanna Rothman Pragmatic &#8230; <a href="http://pradeepc.net/blog/2008/01/10/jolt-awards-2007-finalists/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The books:</p>
<table border="1" cellpadding="1" cellspacing="1">
<tr>
<td colspan="3" bgcolor="#999999"><span class="cathead">General Books</span></td>
</tr>
<tr>
<td rowspan="6" valign="top">&nbsp;</td>
<td valign="top"><em>Beautiful Code</em> Edited by Andy Oram and Greg Wilson</td>
<td valign="top">O&#8217;Reilly</td>
</tr>
<tr>
<td valign="top"><em>Geekonomics: The Real Cost of Insecure Software</em> by David Rice</td>
<td valign="top">Addison-Wesley Professional</td>
</tr>
<tr>
<td valign="top"><em>Manage It!: Your Guide to Modern Pragmatic Project Management</em> by Johanna Rothman</td>
<td valign="top">Pragmatic Bookshelf</td>
</tr>
<tr>
<td valign="top"><em>Myths of Innovation</em> by Scott Berkun</td>
<td valign="top">O&#8217;Reilly</td>
</tr>
<tr>
<td valign="top"><em>Outside In Software Development</em> by Carl Kessler and John Sweitzer</td>
<td valign="top">IBM Press</td>
</tr>
<tr>
<td valign="top"><em>Release It!: Design and Deploy Production-Ready Software</em> by Michael T. Nygard</td>
<td valign="top">Pragmatic Bookshelf</td>
</tr>
<tr>
<td colspan="3" bgcolor="#999999"><span class="cathead">Technical Books</span></td>
</tr>
<tr>
<td rowspan="6" valign="top">&nbsp;</td>
<td valign="top"><em>Continuous Integration: Improving Software Quality and Reducing Risk</em> By Paul Duvall, Steve Matyas, Andrew   Glover</td>
<td valign="top">Addison-Wesley Professional</td>
</tr>
<tr>
<td valign="top"><em>Fuzzing: Brute Force   Vulnerability Discovery</em> By Michael Sutton, Adam   Greene, Pedram Amini</td>
<td valign="top">Addison-Wesley Professional</td>
</tr>
<tr>
<td valign="top"><em>Head First SQL Your Brain   on SQL—A Learner&#8217;s Guide</em> by Lynn   Beighley</td>
<td valign="top">O&#8217;Reilly</td>
</tr>
<tr>
<td valign="top"><em>The Rails Way</em> by Obie Fernandez</td>
<td valign="top">Addison-Wesley Professional</td>
</tr>
<tr>
<td valign="top"><em>WPF Unleashed</em> by Adam Nathan</td>
<td valign="top">Sams Publishing</td>
</tr>
<tr>
<td valign="top"><em>xUnit Test Patterns: Refactoring Test Code</em> by Gerard Meszaros</td>
<td valign="top">Addison-Wesley Professional</td>
</tr>
</table>
<p>The complete list is <a href="http://joltawards.com/finalists.html" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2008/01/10/jolt-awards-2007-finalists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monster Attack</title>
		<link>http://pradeepc.net/blog/2007/08/24/monster-attack/</link>
		<comments>http://pradeepc.net/blog/2007/08/24/monster-attack/#comments</comments>
		<pubDate>Sat, 25 Aug 2007 02:08:48 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/?p=148</guid>
		<description><![CDATA[Well, it is not actually a monster-attack, but an attack on Monster.com by hackers who stole 1.6 Millions records of user data. Several phishing attacks trying to gain more user information, like bank account number and password, were reported. The &#8230; <a href="http://pradeepc.net/blog/2007/08/24/monster-attack/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, it is not actually a monster-attack, but an attack on <a href="http://www.monster.com" target="_blank">Monster.com</a> by hackers who stole 1.6 Millions records of user data. Several phishing attacks trying to gain more user information, like bank account number and password, were reported. The emails were very realistic because they contained the user&#8217;s actual personal information.</p>
<p>Read more of it from <a href="http://news.bbc.co.uk/2/hi/technology/6956349.stm" target="_blank">BBC website</a>.</p>
<p>Monster&#8217;s security notice and advice can be found <a href="http://help.monster.com/besafe/" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2007/08/24/monster-attack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>$150,000 ACM-Infosys Award for Computing Sciences Innovators and Researchers</title>
		<link>http://pradeepc.net/blog/2007/08/22/150000-acm-infosys-award-for-computing-sciences-innovators-and-researchers/</link>
		<comments>http://pradeepc.net/blog/2007/08/22/150000-acm-infosys-award-for-computing-sciences-innovators-and-researchers/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 00:27:00 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/?p=144</guid>
		<description><![CDATA[Infosys does something that all Indians can be proud of. The Association for Computing Machinery (ACM) has signed an agreement with Infosys Technologies Limited to create a new annual award that recognizes young scientists and system developers whose contemporary innovations &#8230; <a href="http://pradeepc.net/blog/2007/08/22/150000-acm-infosys-award-for-computing-sciences-innovators-and-researchers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.infosys.com" target="_blank">Infosys</a> does something that all Indians can be proud of.</p>
<blockquote><p>The <a href="http://www.acm.org" target="_blank">Association for Computing Machinery (ACM) </a>has signed an agreement with Infosys Technologies Limited to create a new annual award that recognizes young scientists and system developers whose contemporary innovations are having a dramatic impact on the computing field. The award, to be known as the ACM-Infosys Foundation Award in the Computing Sciences, will seek candidates globally and will carry a prize of $150,000. The first recipient will be announced as part of the ACM Awards program in early 2008.</p></blockquote>
<p>Read the full press release <a href="http://www.infosys.com/media/press_releases/acm-infosys-award.pdf" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2007/08/22/150000-acm-infosys-award-for-computing-sciences-innovators-and-researchers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

