<?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"
	>

<channel>
	<title>Dotmad.net</title>
	<atom:link href="http://dotmad.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotmad.net/blog</link>
	<description>The Number One Visual Studio 2009 Weblog on the Web</description>
	<pubDate>Thu, 19 Aug 2010 09:07:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>Catching unhandled exceptions</title>
		<link>http://dotmad.net/blog/2010/08/catching-unhandled-exceptions-and-setunhandledexceptionmode/</link>
		<comments>http://dotmad.net/blog/2010/08/catching-unhandled-exceptions-and-setunhandledexceptionmode/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 14:46:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Winforms]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[Exceptions]]></category>

		<category><![CDATA[legacyUnhandledExceptionPolicy]]></category>

		<category><![CDATA[SetUnhandledExceptionMode]]></category>

		<category><![CDATA[ThreadException]]></category>

		<category><![CDATA[UnhandledException]]></category>

		<guid isPermaLink="false">http://dotmad.net/blog/?p=309</guid>
		<description><![CDATA[As a rule, in every application I write, I always implement both the Application.ThreadException and AppDomain.UnhandledException events, to catch exceptions which were not caught by a try..catch block.
There are three reasons behind this:

Present a custom failure message to the user (something like Twitter&#8217;s fail whale message) instead of the default ugly (and unclear) error dialog, [...]]]></description>
			<content:encoded><![CDATA[<p>As a rule, in every application I write, I always implement both the <a onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn2.microsoft.com');" href="http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.threadexception.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn2.microsoft.com');"><span style="color: #999999;">Application.ThreadException</span></a> and <a onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn2.microsoft.com');" href="http://msdn2.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn2.microsoft.com');"><span style="color: #999999;">AppDomain.UnhandledException</span></a> events, <a href="http://dotmad.net/blog/2007/08/dont-propagate-exceptions-to-the-user" >to catch exceptions</a> which were not caught by a try..catch block.</p>
<p>There are three reasons behind this:</p>
<ol>
<li>Present a custom failure message to the user (something like <a href="http://www.readwriteweb.com/archives/the_story_of_the_fail_whale.php" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.readwriteweb.com');">Twitter&#8217;s fail whale</a> message) instead of the default ugly (and unclear) error dialog, i.e. &#8220;XXX<em>.exe has encountered a problem and needs to close. We are sorry for the inconvenience.</em>&#8220;</li>
<li>Log the exception so it may be resolved in future releases.</li>
<li>Although it&#8217;s not considered as a good practice, some exception may be ignored so the application may keep on running, instead of crashing.</li>
</ol>
<p><img class="alignnone size-medium wp-image-310" title="crash" src="http://dotmad.net/blog/wp-content/uploads/2010/08/crash-300x147.jpg" alt="" width="300" height="147" /><a href="http://dotmad.net/blog/wp-content/uploads/2010/08/crash.jpg" ></a></p>
<p>However, I recently came across a case in which the application crashed ungracefully although I implemented those methods. Some research led to me to realize my code is not as full-proof as I thought it was.</p>
<p>The code below will crash your application even if you hooked the two events mentioned above. The UnhandledException event WILL be executed, but afterwards the application will crash anyway, presenting Microsoft&#8217;s default error dialog:</p>
<blockquote><p>private void MyThreadProc()<br />
{<br />
    throw new Exception(&#8221;Bad wolf&#8221;);<br />
}</p>
<p>private void ClickMe()<br />
{<br />
    Thread myThread = new Thread(new ThreadStart(MyThreadProc));<br />
    myThread.Start();<br />
}</p></blockquote>
<p>Turns out I was not aware that during the transition between Framework 1.1 and 2.0 (and beyond), Microsoft <a href="http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/674d33b5-b199-4f6d-ae79-d32c66d955be" onclick="javascript:pageTracker._trackPageview('/outbound/article/social.msdn.microsoft.com');">changed the way the CLR deals with exception</a> that don&#8217;t occurs in the application&#8217;s main thread, meaning that if you want the application to remain alive even after an external thread exception, you need to tell the CLR to revert to the Framework 1.1 exception handling mechanism, by adding this section to your app.config file:</p>
<blockquote><p><span style="font-family: 'Courier New'; color: blue;"><strong>&lt;</strong></span><span style="font-family: 'Courier New'; color: maroon;">configuration</span><strong><span>&gt; <br />
<span style="mso-spacerun: yes">  </span>&lt;</span><span style="font-family: 'Courier New'; color: maroon;">runtime</span></strong><strong><span>&gt; <br />
<span style="mso-spacerun: yes">    </span>&lt;</span><span style="font-family: 'Courier New'; color: maroon;">legacyUnhandledExceptionPolicy</span><span style="font-family: 'Courier New'; color: fuchsia;"> </span><span style="font-family: 'Courier New'; color: red;">enabled</span><span style="font-family: 'Courier New'; color: blue;">=&#8221;1&#8243;</span><span style="font-family: 'Courier New'; color: fuchsia;"> </span></strong><strong><span style="font-family: 'Courier New'; color: blue;">/&gt; <br />
</span><span style="font-family: 'Courier New'; color: blue;"><span style="mso-spacerun: yes">  <span style="font-family: 'Courier New'; color: blue;">&lt;</span></span></span><span style="font-family: 'Courier New'; color: maroon;">runtime</span></strong><strong><span style="font-family: 'Courier New'; color: blue;">&gt;<br />
</span><span style="font-family: 'Courier New'; color: maroon;"><span style="font-family: 'Courier New'; color: blue;">&lt;</span>configuration</span><span style="font-family: 'Courier New'; color: blue;">&gt; </span></strong></p></blockquote>
<p>Again, not a best practice, but if you can&#8217;t afford to having</p>
<p>Another footnote is related to using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.setunhandledexceptionmode.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">Application.SetUnhandledExceptionMode</a>Method. If you try setting it from a Winform application running inside the Visual Studio, you&#8217;ll get the following error: &#8220;<strong><em>Application exception mode cannot be changed once any Controls are created in the application</em></strong>&#8220;, even if that&#8217;s the first line of code in the application. This is because the Visual Studio runs a host environment <strong>prior</strong> to running your application. The methods works just fine when you run it from outside the Visual Studio.</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmad.net/blog/2010/08/catching-unhandled-exceptions-and-setunhandledexceptionmode/feed/</wfw:commentRss>
		</item>
		<item>
		<title>So you got over a million followers on Twitter</title>
		<link>http://dotmad.net/blog/2009/09/so-you-got-over-a-million-followers-on-twitter/</link>
		<comments>http://dotmad.net/blog/2009/09/so-you-got-over-a-million-followers-on-twitter/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 11:22:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Social Media]]></category>

		<category><![CDATA[Twitter]]></category>

		<category><![CDATA[TwitterAnalyzer]]></category>

		<guid isPermaLink="false">http://dotmad.net/blog/?p=307</guid>
		<description><![CDATA[( * Originally posted as &#8220;The Million Followers Fallacy&#8221; on &#8220;Pravda on Media and Tech&#8221; )
Twitter is getting more and more attention from &#8220;old media&#8221; lately. Whether it&#8217;s a news-story mentioning Twitter, a Twitter competition between a celebrities, or using Twitter to gather reports on the Iran elections, the average person sees the word &#8220;Twitter&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>( * Originally posted as &#8220;<a href="http://pravdam.com/2009/08/20/the-million-followers-fallacy-guest-post-by-adi-avnit/" onclick="javascript:pageTracker._trackPageview('/outbound/article/pravdam.com');">The Million Followers Fallacy</a>&#8221; on &#8220;<a href="http://pravdam.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/pravdam.com');">Pravda on Media and Tech</a>&#8221; )</em></strong></p>
<p>Twitter is getting more and more attention from &#8220;old media&#8221; lately. Whether it&#8217;s a news-story mentioning Twitter, a <a href="http://www.cnn.com/2009/TECH/04/15/ashton.cnn.twitter.battle/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.cnn.com');" target="_blank">Twitter competition</a> between a celebrities, or using Twitter to gather reports on the <a href="http://www.thenation.com/blogs/notion/443634" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.thenation.com');" target="_blank">Iran elections</a>, the average person sees the word &#8220;Twitter&#8221; more and more often lately.</p>
<p>But with the Twitter rush a new bubble seems to be forming.</p>
<p>Remember the days of the 2000 Dot-Com bubble, in which every site displaying a million page-views could raise money as though it had already become profitable?<br />
I feel we are repeating the same mistake, only in social media.</p>
<p>The new fashion among some Twitter users, individuals or companies, is to brag about the number of &#8220;followers&#8221; they have for their Twitter account, or the number of followers their employees have. Encouraged by this there is a host on new &#8220;services&#8221;, promising user to boost their followers count for a small fee. There is also a new buzz-word: &#8220;Reach&#8221;. Those self-proclaimed Twitter experts will use tools like <a href="http://twitteranalyzer.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/twitteranalyzer.com');" target="_blank">TwitterAnalyzer</a> to show others that their Tweets are supposedly read by even more people than their Twitter followers, using a repeat publication (&#8221;Retweets&#8221;).</p>
<div class="im">
<p>And there lies the illusion.</p>
<p><strong></strong><br />
<strong><span style="font-size: medium;">The number of Twitter followers (or reach) is usually meaningless</span></strong></p>
<p>Twitter usage is based on the magic principle of following/followers. You follow other users that may interest you, and being followed in turn by others who find your updates interesting.<br />
But suppose you just opened an account on Twitter - how do you get followers?</p>
<p>If you are a celebrity like Ashton Kutcher, have a TV show like Opera, a successful blogger like Robert Scoble, or simply a leading TV channel like CNN, than you have it easy - you just need to mention your new Twitter account and the masses will follow you.<br />
But you need to be well-known to the public prior to opening a Twitter account.</p>
<p>But what if you are an average Joe, looking to become a superstar on Twitter?<br />
You can use an unwritten rule, saying that if someone is following you, it&#8217;s polite to follow that person back. Twitter users interested in inflating the number of followers they have simply need to follow thousands of others, hoping those others will follow them back.<br />
The less ethical among them wait for another to follow, and than stop following that person.<br />
To sum it up: such a user has 20000 followers, not because he is THAT interesting to them, but simply out of politeness.</p>
<p>The principle behind &#8220;Reach&#8221; is similar: if you wrote an update, and one of your 20000 followers repeats it, and that person has another 10000 followers (not shared by you), your message could have been read by 30000 folks. But again, people exploit the technology, and open multiple accounts, each of them having thousands of followers (as previously mentioned), and than repeat that message from all their accounts. Twitter defines this as Spam.</p>
<div class="im">
<p>In addition to all that, there is the face that 10-50% of all followers are either dormant/inactive accounts, bots, spammers, or other irrelevant accounts.</p>
<p><strong><span style="font-size: medium;">Million follower don&#8217;t actually read your updates</span></strong></p>
<p>And suppose Mr. Kutcher writes something on his Twitter account, does that mean all of his million (plus) followers actually read it? Of course not!</p>
<p>On my <a href="http://twitter.com/dotmad" onclick="javascript:pageTracker._trackPageview('/outbound/article/twitter.com');" target="_blank">personal</a> Twitter account I follow only about 200 people. Each one publishes a number of updates during the day, reaching thousands of updates each day. Since I&#8217;m not sitting glued to the screen, when I check for updates I usually see only updates from the past 30-60 minutes. Written something when I wasn&#8217;t checking for updates? I&#8217;ll probably miss your update.</p>
<p>To put it differently, if you wrote an update and have a reach of 100000 users, it&#8217;s 100000 of users with the <strong>potential</strong> to read your update, but most likely most of them <strong>will never see it</strong>.</p>
<p>So don&#8217;t be tempted by false promises from Twitter &#8220;experts&#8221;. We are light years away from a reliable, measurable advertising model on Twitter.</p></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dotmad.net/blog/2009/09/so-you-got-over-a-million-followers-on-twitter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Looking back on social media and myself</title>
		<link>http://dotmad.net/blog/2009/08/looking-back-on-social-media-and-myself/</link>
		<comments>http://dotmad.net/blog/2009/08/looking-back-on-social-media-and-myself/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 20:40:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Blogging]]></category>

		<category><![CDATA[Facebook]]></category>

		<category><![CDATA[Social networks]]></category>

		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://dotmad.net/blog/?p=305</guid>
		<description><![CDATA[More than 2 years ago, Ayelet Noff (AKA Blonde 2.0)  wrote a post on social networks vs. blogs (with Myspace as an example for a social network). She claimed there is room for both in the life of a blogger.
I disagreed with her:
&#8220;Blogging takes effort, time and at least a little talent.
MySpace requires choosing a [...]]]></description>
			<content:encoded><![CDATA[<p>More than 2 years ago, Ayelet Noff (AKA <a href="http://www.blonde2dot0.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.blonde2dot0.com');">Blonde 2.0</a>)  wrote a post on <strong>social networks vs. blogs</strong> (with Myspace as an example for a social network). She claimed there is room for both in the life of a blogger.</p>
<p>I <a href="http://dotmad.net/blog/2007/05/blogs-vs-social-networks/" >disagreed</a> with her:</p>
<blockquote><p>&#8220;Blogging takes effort, time and at least a little talent.<br />
MySpace requires choosing a template.<br />
Blogging is about sharing your view, opinions and (some times) personal life with your readers.<br />
MySpace is about sharing links to your “friends”, meaning other pages in which the only meaningful data is links to more “friends” and so on.<br />
(Why do I use quotes? ask <a onclick="javascript:pageTracker._trackPageview('/outbound/article/blog.outer-court.com');" href="http://blog.outer-court.com/archive/2005-10-13-n73.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/blog.outer-court.com');">Samy</a>)</p>
<p>If a blog is the equivalent of an autobiography, MySpace page is the equivalent of a phone book.&#8221;</p></blockquote>
<p><strong>And</strong></p>
<blockquote><p>&#8220;I think that with some social networks (MySpace again) you need to do most of the work OUTSIDE the site by mails, IM, phone, etc.<br />
In other words, the SN site itself gives very few tools to help you make new friends, while a blog gives you information on the writer on it’s own.</p>
<p>Bloggers must invest more effort, while people on social networks can do it.<br />
The result is that the chance of encountering a social network page containing meaningfull information is lower.<br />
Blogging has a much higher entry bar than most social networks.&#8221;</p></blockquote>
<p>Funny reading it now.</p>
<p>I can&#8217;t image my life today without social networks. I&#8217;m still not using Myspace, but constantly use <a href="http://www.facebook.com/adi.av" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.facebook.com');">Facebook</a> and <a href="http://twitter.com/dotmad" onclick="javascript:pageTracker._trackPageview('/outbound/article/twitter.com');">Twitter</a>. I have met many fascinating people through social networks, went to events I would have never heard of without them, and learned a lot using them.</p>
<p>In fact, using social networks to that extent also affected my writing, as after channeling creativity using Twitter I&#8217;m often left without any for a new blog post. On the other hand, I have recently wrote a post on my Hebrew blog, posted on Twitter - and got a tremendous  response, as people liked the content and promoted it on their own.</p>
<p>In fact, the focus of the problem today has shifted from &#8220;<em>Social networks vs. blogs</em>&#8221; to large vs. small communities on social networks, but that&#8217;s a topic for another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmad.net/blog/2009/08/looking-back-on-social-media-and-myself/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rotating Graphics</title>
		<link>http://dotmad.net/blog/2009/03/rotating-graphics/</link>
		<comments>http://dotmad.net/blog/2009/03/rotating-graphics/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 17:12:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Useful .Net classes]]></category>

		<category><![CDATA[RotateAt]]></category>

		<category><![CDATA[TranslateTransform]]></category>

		<guid isPermaLink="false">http://dotmad.net/blog/?p=302</guid>
		<description><![CDATA[This is a fairly simple issue, but I had to rotate a drawn shape recently.
Initial searches led me to the TranslateTransform method, but I learned there is a simpler way to achieve this, using the RotateAt method of the Matrix class:
Graphics g = this.CreateGraphics(); //get a graphics object for the form
g.DrawRectangle(new Pen(Color.Black), 50, 50, 100, 100); //normal [...]]]></description>
			<content:encoded><![CDATA[<p>This is a fairly simple issue, but I had to rotate a drawn shape recently.</p>
<p>Initial searches led me to the <a href="http://msdn.microsoft.com/en-us/library/system.drawing.graphics.translatetransform.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">TranslateTransform</a> method, but I learned there is a simpler way to achieve this, using the <a href="http://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.matrix.rotateat.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">RotateAt</a> method of the Matrix class:</p>
<div dir="ltr"><strong>Graphics g = this.CreateGraphics();</strong> //get a graphics object for the form<br />
<strong>g.DrawRectangle(new Pen(Color.Black), 50, 50, 100, 100);</strong> //normal drawing<strong>Matrix oldMatrix = g.Transform;</strong> //save the old Matrix object<strong>Matrix myMatrix = new Matrix();</strong> //create a new Matrix object</p>
<p><strong>myMatrix.RotateAt(15, new PointF(200.0f, 200.0f));</strong> //rotate the matrix in relation to a specific point (200, 200) by 15 degrees<br />
<strong>g.Transform = myMatrix;</strong> //assign the new (rotated) matrix to the graphics object<br />
<strong>g.DrawRectangle(new Pen(Color.Black), 100, 100, 100, 100);</strong> //perform the drawing</p>
<p><strong>g.Transform = oldMatrix;</strong> //restore the original matrix</div>
<p>The result:</p>
<p><a href="http://dotmad.net/blog/wp-content/uploads/2009/03/sample.jpg" ><img class="alignnone size-medium wp-image-303" title="sample" src="http://dotmad.net/blog/wp-content/uploads/2009/03/sample.jpg" alt="" width="294" height="232" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://dotmad.net/blog/2009/03/rotating-graphics/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The role of Clients and Services in WCF</title>
		<link>http://dotmad.net/blog/2009/02/the-role-ofclients-and-services-in-wcf/</link>
		<comments>http://dotmad.net/blog/2009/02/the-role-ofclients-and-services-in-wcf/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 18:08:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://dotmad.net/blog/?p=299</guid>
		<description><![CDATA[I have seen this question in Stackoverflow.com, and I want to answer it here:
Greetings readers! So I am trying to develop a client server system.. Since I have not designed a client server system before, I thought that I would post a question and see what the experts here have to say.
Requirements: .NET 3.5 WCF [...]]]></description>
			<content:encoded><![CDATA[<p>I have seen this question in <a href="http://stackoverflow.com/questions/539513/please-recommend-an-architecture-for-my-system" onclick="javascript:pageTracker._trackPageview('/outbound/article/stackoverflow.com');">Stackoverflow.com</a>, and I want to answer it here:</p>
<blockquote><p><em>Greetings readers! So I am trying to develop a client server system.. Since I have not designed a client server system before, I thought that I would post a question and see what the experts here have to say.</em></p>
<p><em>Requirements: .NET 3.5 WCF minimum of 2 computers, Master and Slave.</em></p>
<p><em>The use case is a testing environment, where the slave runs tests at the request of the master. </em></p>
<p><em>Questions: I would prefer that the slaves locate and connect to the master, and then the master takes control and is the one that initiates the tests to be run. The slave also makes progress reports: new test data, unexpected events, etc.</em></p>
<p><em>The part that I am confused about is that if the slave initiates contact with the master, doesn&#8217;t that make him the master? </em></p>
<p><em>Does this mean that I need servicehosts on both slave and master so that they can initiate activity?</em></p></blockquote>
<p>Most channels in WCF are basically a one-way communication, in a sense only one side (<strong><em>WCF Client</em></strong>) can initiate requests - the other side (<strong><em>WCF Service</em></strong>) cannot initiate calls, only respond to them.</p>
<p>There are two possible solutions to the problem presented here:</p>
<ol>
<li>The tester slave (WCF client) initiates the connection to the tester master (WCF service). Afterwards it polls the tester master periodically to receives a list of tests to run.</li>
<li>The tester slave (as a WCF client) initiates the connection to the tester master (as a WCF service). In response, the tester master (now as a WCF client) initiates a <strong>second connection</strong> to the tester client (now as a WCF service). The tester master than sends tests requests to the tester slave.</li>
</ol>
<p>Both architectural approaches can be implemented regardless of the channel type, MSMQ, Tcp/Ip or otherwise.</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmad.net/blog/2009/02/the-role-ofclients-and-services-in-wcf/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Garbage collector, gen2 and memory abuse</title>
		<link>http://dotmad.net/blog/2009/01/garbage-collector-gen2-and-memory-abuse/</link>
		<comments>http://dotmad.net/blog/2009/01/garbage-collector-gen2-and-memory-abuse/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 20:43:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Windows]]></category>

		<category><![CDATA[Garbage collector]]></category>

		<category><![CDATA[GC]]></category>

		<category><![CDATA[gen2]]></category>

		<category><![CDATA[Virtual Size]]></category>

		<guid isPermaLink="false">http://dotmad.net/blog/?p=263</guid>
		<description><![CDATA[There are limits most application developers never encounter. One of them is the 2GB memory limit for applications running on a 32bit operating system.
But what happens if your application is a memory consumer (and most GIS applications are)?
You may find out your application tends to crash and burn once reaching a memory signature of a [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">There are limits most application developers never encounter. One of them is the 2GB memory limit <a href="http://dotmad.net/blog/wp-content/uploads/2008/12/rwl13918af_0015-1024-wince.jpg" ><img class="alignright size-medium wp-image-268" title="rwl13918af_0015-1024-wince" src="http://dotmad.net/blog/wp-content/uploads/2008/12/rwl13918af_0015-1024-wince-240x300.jpg" alt="" width="181" height="215" /></a>for applications running on a 32bit operating system.</p>
<p>But what happens if your application is a memory consumer (and most GIS applications are)?</p>
<p>You may find out your application tends to crash and burn once reaching a memory signature of a little over 1GB.</p>
<p>It&#8217;s a common knowledge for developers (I hope) that a useful way to measure application&#8217;s true memory consumption is using the Task manager&#8217;s &#8220;VM Size&#8221; column (as the &#8220;Mem Usage&#8221; column only indicates the size of the application&#8217;s Working Set). So why does the application crash when supposedly there is still plenty of free memory?</p>
<p>There are 2 possible answers:</p>
<ol>
<li>Although a certain size of memory is allocated to the application, fragmentation to the memory may cause the application to actually consume more than that. This may also be related to the GC behavior in relation to 2nd generation objects, which I&#8217;ll discuss later.</li>
<li>The VM Size column does not represent the actual Virtual address space allocated to the application, which is limited to 2-3GB on a 32bit OS. In addition to the allocated memory the OS may have designated addition shared memory (shared with other applications, but still counts towards the 2GB limit). To view the actual size of memory allocated by the OS to the application, use the Perfmon.exe tool&#8217;s Virtual Size counter:</li>
</ol>
<p><img title="Virtual Bytes" src="http://dotmad.net/blog/wp-content/uploads/2008/12/windowslivewriter5fb67a3875b6-fcccimage07.png" alt="" width="486" height="480" /></p>
<h3>The .Net Garbage Collector and 2nd generation (gen2) collections</h3>
<p>The GC algorithm divides the allocated objects to 3 generations (0-2), when generation 0 objects are retrieved most frequently and &#8220;live&#8221; for the shortest amount of time. Generation 1 objects are collected less frequently and generation 2 collections are truely a rare occasion.</p>
<p>But when does the GC collects generation 2 allocations (&#8221;full&#8221; collection)? What triggers such a collection?</p>
<p>Surprisingly I found very little information of this subject, but the information I did find, combined with experimentation led to the conclusion such collection occurs when the <strong>overall system</strong> is low on <strong>physical</strong> memory.</p>
<p>Now, let&#8217;s consider the implications for a 4GB computer running a 32bit OS. While the gen2 heap may inflate over time (especially considering large objects are also collected only in gen2 collections), the GC will never trigger as a single application can never consume the entire amount of memory on the computer (being limited to 2GB). However, this may lead to a memory leak and eventually crashing the application (once it&#8217;s virtual address space reaches 2GB).</p>
<p>The solution? Call the GC.Collect() method yourself to trigger a full collection.</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmad.net/blog/2009/01/garbage-collector-gen2-and-memory-abuse/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Juval Lowy and .NET Service Bus</title>
		<link>http://dotmad.net/blog/2009/01/juval-lowy-and-net-service-bus/</link>
		<comments>http://dotmad.net/blog/2009/01/juval-lowy-and-net-service-bus/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 20:21:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[WCF]]></category>

		<category><![CDATA[.Net Service Bus]]></category>

		<category><![CDATA[Azure]]></category>

		<category><![CDATA[Cloud]]></category>

		<guid isPermaLink="false">http://dotmad.net/blog/?p=291</guid>
		<description><![CDATA[I have recently been to an Israeli user group meeting in which iDesign&#8217;s Juval Lowy gave a lecture about the new Azure .Net Service Bus for web services written in WCF.
Basically a service bus is a router, similar to the one you use in your office network. Instead of needing to update the configuration for [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been to an Israeli user group meeting in which <a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=3&amp;tabid=5" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.idesign.net');">iDesign&#8217;s Juval Lowy</a> gave a lecture about the new Azure <a href="http://www.microsoft.com/azure/servicebus.mspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.microsoft.com');">.Net Service Bus</a> for web services written in WCF.</p>
<p>Basically a <strong>service bus</strong> is a router, similar to the one you use in your office network. Instead of needing to update the configuration for multiple clients each time a service they are connected to is moved to a new location or changes channel, all clients/services connect to a central hub. In this case the service bus is located online, somewhere on Microsoft servers.</p>
<p><img class="alignnone" title="service bus" src="http://www.microsoft.com/azure/images/service_bus1.jpg" alt="" width="250" height="170" /></p>
<p>Here is what the <a href="http://beta.blogs.microsoft.co.il/blogs/usergroups/archive/2008/12/17/193985.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/beta.blogs.microsoft.co.il');">meeting&#8217;s page</a> says about the lecture:</p>
<blockquote><p>The .NET services bus is part of the new Microsoft Cloud Computing Windows Azure initiative, and arguably, it is the most accessible, ready to use, powerful, and needed piece. The service bus allows clients to connects to services across any machine, network, firewall, NAT, routers, load balancers, virtualization, IP and DNS as if they were part of the same local network, and doing all that without compromising on the programming model or security. The service bus also supports callbacks, event publishing, authentication and authorization and doing all that in a WCF-friendly manner. This session will present the service bus programming model, how to configure and administer service bus solutions, working with the dedicated relay bindings including the available communication modes, relying on authentication in the cloud for local services and the various authentication options, and how to provide for end-to-end security through the relay service. You will also see some advanced WCF programming techniques, original helper classes, productivity-enhancing utilities and tools, as well as discussion of design best practices and pitfalls.</p></blockquote>
<p>Although Juval clearly know a lot on the subject, and apparently is currently doing a tour lecture on the subject (at least in Israel and <a href="https://beta.blogs.msdn.com/architectsrule/archive/2009/01/05/wcf-with-regards-to-cloud-computing-and-azure.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/beta.blogs.msdn.com');">Belgium</a>), I have to say the talk was not very interesting for experienced WCF developers. This is due to the fact the interface is almost identical to that of a simple WCF service, therefor I kept getting a feeling of &#8220;<em>been there, done that</em>&#8220;. It&#8217;s very easy to work the .NET service bus.</p>
<p>The .NET service bus supports both TCP/IP and HTTP based connections (highlight of the lecture: &#8220;<em>to add WS support just add an ass</em>&#8220;), and allows both connectivity through the <a href="http://blogs.msdn.com/clemensv/archive/2008/10/27/azure-microsoft-net-service-bus.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/blogs.msdn.com');">cloud or P2P</a> (after negotiation). There is a limited usage to SSL transport level security, something that alarms me a bit, as this is the best performance/security ratio option in WCF.</p>
<p>I do have to wonder regarding the usability of this platform. Many companies I know moved to <a href="http://en.wikipedia.org/wiki/Service-oriented_architecture" onclick="javascript:pageTracker._trackPageview('/outbound/article/en.wikipedia.org');">SOA </a>architecture, splitting central servers to many services. Such systems need a service bus residing inside the local network due to two reasons:</p>
<ol>
<li>Local network is more secure. Although Mr. Lowy waved his hands and replied &#8220;message level security is NP complete&#8221; to a question on the subject, I doubt IT managers or security officers in large firms would accept that.</li>
<li>Local network is faster. Although a large downwards bandwidth is easily obtained, for a true 2 way communication you need a decent outgoing bandwidth (unlike ADSL lines, for example), and that&#8217;s not cheap.</li>
</ol>
<p>There are local alternatives, both commercial (<a href="http://www.microsoft.com/biztalk/solutions/soa/esb.mspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.microsoft.com');">Microsoft Biztalk server</a>) and open source (<a href="http://www.udidahan.com/category/nservicebus/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.udidahan.com');">Udi Dahan</a>&#8217;s <a href="http://www.nservicebus.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.nservicebus.com');">NServiceBus</a>).</p>
<p>I guess only time will tell if this new technology is successful.</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmad.net/blog/2009/01/juval-lowy-and-net-service-bus/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Visual Studio 2009 is out, welcome VS2010</title>
		<link>http://dotmad.net/blog/2008/12/visual-studio-2009-is-out-welcome-vs2010/</link>
		<comments>http://dotmad.net/blog/2008/12/visual-studio-2009-is-out-welcome-vs2010/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 21:26:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<category><![CDATA[Visual Studio 2009]]></category>

		<category><![CDATA[VS2009]]></category>

		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://dotmad.net/blog/?p=283</guid>
		<description><![CDATA[Some time ago, frustrated with my RSS reader being overrun by VS2008 beta announcements, I wrote a short post announcing the release of VS 2009 beta 1. And although there are some calls to re-brand the most recent service pack, I doubt we&#8217;ll see this version.
Instead we got Visual Studio 2010, with new features such [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, frustrated with my RSS reader being overrun by VS2008 beta announcements, I wrote a short post announcing the <a href="http://dotmad.blogspot.com/2007/07/visual-studio-2009-beta-1-is-available.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/dotmad.blogspot.com');">release of VS 2009 beta 1</a>. And although <a href="http://blogs.zdnet.com/microsoft/?p=1523" onclick="javascript:pageTracker._trackPageview('/outbound/article/blogs.zdnet.com');">there are some calls</a> to re-brand the most recent service pack, I doubt we&#8217;ll see this version.</p>
<p>Instead we got <a href="http://www.microsoft.com/visualstudio/products/2010/default.mspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.microsoft.com');">Visual Studio 2010</a>, with new features such as support for cloud computing, parallel extensions, ASP.NET MVC, etc.</p>
<p>Frankly, I&#8217;m not that excited.<br />
Most of the features to be included in the upcoming version are already available to developers as additions to existing developing tools (although most are in CTP mode at the moment).<br />
There ARE the new features of <strong>C# 4.0</strong>, but unlike the changes between 1.1 and 2.0, the most recent set of changes is &#8220;nice to have&#8221; at most.</p>
<p>What is more impressive (in my opinion) are the changes and improvements in the new <strong>Visual Studio Team System</strong> package, which had a lot of room for improvement even after the latest service pack, and especially the new and improved <a href="http://blogs.msdn.com/charles_sterling/archive/2008/11/05/visual-studio-team-system-2010-test-features-walk-through-with-screen-shots.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/blogs.msdn.com');">tester version</a>.</p>
<p>Considering the release of VS2008, we&#8217;ll probably be able to see a stable version (beta 2) at the second half of the year 2009.</p>
<p><em>Anders Hejlsberg, Mads Torgersen and Eric Lippert discuss the new features of C# 4.0</em><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/KzSY9WQXjzg&amp;hl=en&amp;fs=1" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/KzSY9WQXjzg&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://dotmad.net/blog/2008/12/visual-studio-2009-is-out-welcome-vs2010/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Validation</title>
		<link>http://dotmad.net/blog/2008/12/validation/</link>
		<comments>http://dotmad.net/blog/2008/12/validation/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 21:37:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dotmad.net/blog/?p=279</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/Cbk980jV7Ao&amp;hl=en&amp;fs=1" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/Cbk980jV7Ao&amp;hl=en&amp;fs=1"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://dotmad.net/blog/2008/12/validation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The dangers of static members</title>
		<link>http://dotmad.net/blog/2008/12/the-dangers-of-static-members/</link>
		<comments>http://dotmad.net/blog/2008/12/the-dangers-of-static-members/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 23:30:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<category><![CDATA[Winforms]]></category>

		<guid isPermaLink="false">http://dotmad.net/blog/?p=264</guid>
		<description><![CDATA[(If you use Visual Studio 2003 or you tend to ignore compiler warnings, this post is for you)
Static classes and members have their uses. However, I recently encountered a dangerous pitfall regarding their usage.
Consider the following code:
public static class MyClass
{
    public static int myVal = MyClass.myVal;
    public static MyOtherClass myClass = MyClass.myClass;
    public static Color [...]]]></description>
			<content:encoded><![CDATA[<p><em>(If you use Visual Studio 2003 or you tend to ignore compiler warnings, this post is for you)</em></p>
<p>Static classes and members have their uses. However, I recently encountered a dangerous pitfall regarding their usage.</p>
<p>Consider the following code:</p>
<blockquote><p>public static class MyClass<br />
{<br />
    public static int myVal = MyClass.myVal;<br />
    public static MyOtherClass myClass = MyClass.myClass;<br />
    public static Color myColor = MyClass.myColor;<br />
}</p></blockquote>
<p>Can you spot what is wrong here?</p>
<p>You got it right - this class assign it&#8217;s members back to themselves, effectively avoiding assigning them.</p>
<p>If you try using this code using VS2003 it will compile without any notification. In more recent version you&#8217;ll only get a compiler warning.</p>
<p>What&#8217;s worse yet: you can make the member private and the code would still compile.</p>
<p><em>But it can get even worse:<br />
</em>Since these members are not assigned, with value types you&#8217;ll get the default value, while with most classes you&#8217;ll have a null reference.<br />
But the Color struct is something different. It retains an <a href="http://msdn.microsoft.com/en-us/library/system.drawing.color.empty.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">Empty</a> value, and if your winform application uses the default theme and colors, assigning an empty color to a control basically does nothing.<br />
Now try understanding why your panel refuses to change color&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmad.net/blog/2008/12/the-dangers-of-static-members/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
