<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3636350767852723387</id><updated>2012-01-30T16:44:55.790Z</updated><category term='C#'/><category term='PHP'/><category term='WF'/><category term='LINQ'/><category term='CLR'/><category term='books'/><category term='MicroFramework'/><category term='SQL Server'/><category term='SyBase'/><category term='VB.NET'/><category term='JavaScript'/><category term='IIS'/><category term='WPF'/><category term='Silverlight'/><category term='ASP.NET'/><title type='text'>&lt;cesarafonso /&gt;</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>32</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-952857044049819892</id><published>2012-01-30T16:30:00.003Z</published><updated>2012-01-30T16:44:55.795Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='VB.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>nop - No Operation</title><content type='html'>&lt;div align="justify"&gt;If you ever looked at your code compiled in DebugMode &lt;i&gt;Versus&lt;/i&gt; ReleaseMode you most certainly saw a few differences. One of those differences is the higher presence of the &lt;b&gt;nop&lt;/b&gt; IL instruction in the DebugMode. What does this instruction do? Well, nothing "meaningful"...&lt;/div&gt;&lt;div align="justify"&gt;Take a look at the following simple example:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20120130NOP1" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 210px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20120130/nop1.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20120130/nop1.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=500,width=900');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;As you can see, I have a breakpoint set on the bracket. If we compile this in DebugMode you can see that the compiler inserted a &lt;b&gt;nop&lt;/b&gt; instruction right after the anonymous methods "signature":&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20120130NOP2" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 117px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20120130/nop2.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20120130/nop2.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=420,width=1020');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;And in release mode, it didn't:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20120130NOP3" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 109px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20120130/nop3.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20120130/nop3.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=420,width=1020');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The compiler inserts &lt;b&gt;nop&lt;/b&gt; instructions as placeholders for the non-executing lines of code (since non-executing lines are not translated into IL instructions). This is the reason why we can set breakpoints on brackets. The &lt;b&gt;nop&lt;/b&gt; instruction does not perform any "meaningful" work yet it can consume a processing cycle.&lt;/div&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-952857044049819892?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/952857044049819892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=952857044049819892&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/952857044049819892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/952857044049819892'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2012/01/nop-no-operation.html' title='nop - No Operation'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-3146322126249702855</id><published>2011-11-24T09:23:00.004Z</published><updated>2011-11-24T09:28:38.194Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>callvirt</title><content type='html'>&lt;div align="justify"&gt;The first release of the .NET Framework was about 10 years ago (13 February 2002). How well do you know the framework? Take a look at the following class:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20111124CallVirt01" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 145px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt01.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt01.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=300,width=700');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Simple. A static field, a static method and an instance method. Both methods return the static field. Now, imagine that we have the following in main:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20111124CallVirt02" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 162; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt02.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt02.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=400,width=800');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;As you probably noticed, there's an instance call using a null reference. So, the first idea that pops up in your head when someasks "Will this code throw an exception?" is "Yes, it will! A NullReference exception to be exact". Well, if we compile it and run it using Visual Studio, it will actually throw an exception:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20111124CallVirt03" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 131; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt03.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt03.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=300,width=800');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;So, what's the catch? Well, the right answer to the question above is "It depends". If we look at the generated IL, we can see that the compiler emmited the "callvirt" instruction for the instance method:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20111124CallVirt04" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 374px; CURSOR: pointer; HEIGHT: 271; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt04.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt04.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=400,width=500');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;That's the normal behaviour. The C# compiler emmits a callvirt instruction on every instance method. It does so in order to check for an object reference at runtime (TypeSafety). But, if we write the exact same code in IL and replace the callvirt by a call instruction and compile it using ILASM:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20111124CallVirt05" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 354px; CURSOR: pointer; HEIGHT: 230; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt05.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt05.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=400,width=500');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;It works:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20111124CallVirt06" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 116; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt06.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt06.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=300,width=800');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;This is because the instance method is only using a static field and, at that point of the code, the type constructor already did it's work and the method works fine. If you look at both the assemblies ("C# Compiled" and "ILASM compiled") in .NET Reflector, both generate the following C# code (Main):&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20111124CallVirt07" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 182; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt07.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20111124/callvirt07.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=400,width=800');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;If you ever get the change to read this, thanks MC.&lt;/div&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-3146322126249702855?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/3146322126249702855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=3146322126249702855&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/3146322126249702855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/3146322126249702855'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2011/11/callvirt.html' title='callvirt'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-1866949367330424699</id><published>2011-09-08T10:11:00.005+01:00</published><updated>2011-11-17T16:39:54.109Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='MicroFramework'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>Everything is volatile (.NET Micro)</title><content type='html'>&lt;div align="justify"&gt;If you ever builted multithreaded applications, you most certainly came across the volatile keyword. As &lt;a href="http://msdn.microsoft.com/en-us/library/x13ttww7(v=VS.100).aspx" target="_blank"&gt;stated on MSDN&lt;/a&gt;, "The volatile keyword indicates that a field might be modified by multiple threads that are executing at the same time. Fields that are declared volatile are not subject to compiler optimizations that assume access by a single thread. This ensures that the most up-to-date value is present in the field at all times". Just recently, I needed this "volatile behaviour" in a .NET MicroFramework project. But when using the keyword "volatile" the compiler actually yielded an error:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110908CompilerError" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 284px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20110908/compilererror.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20110908/compilererror.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=540,width=740');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;What? IsVolatile is not defined? After googling a little I ended up on a blogpost from de .NET Micro development team. Turns out that everything is treated as volatile in the .NET MicroFramework. Well, it makes sense...&lt;/div&gt;&lt;br/&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=31" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-1866949367330424699?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/1866949367330424699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=1866949367330424699&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/1866949367330424699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/1866949367330424699'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2011/09/everything-is-volatile-net-micro.html' title='Everything is volatile (.NET Micro)'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-5083598919796364067</id><published>2011-09-05T14:21:00.006+01:00</published><updated>2011-10-06T11:20:15.535+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>Block Scope</title><content type='html'>&lt;div align="justify"&gt;From time to time, coworkers come to me asking for help. Whenever I have the time, I'm glad to help out. The last help request was actually quite interesting. Here it goes:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Take a look at the following C# code:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110904BS_CSharp1" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 329px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_CSharp1.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_CSharp1.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=500,width=600');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;In the above code, we're using the "i" variable from the loop in an anonymous method. Later on, we print the result of the method execution. Now, what do you expect to get printed in the console? At a glance, some would say " 0 1 2 3 4 5 6 7 8 9 ", since we're iterating from 0 to 10 (excluded). But no. What actually comes out is a sequence of the integer "10":&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110904BS_CSharp2" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 202px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_CSharp2.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_CSharp2.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=400,width=720');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;What? Why? Well, since the "i" variable is used in an anonymous method that &lt;b&gt;does not&lt;/b&gt; get executed in the first "for" loop, the "i" variable will actually have the last value stored (10 because "i" gets incremented one last time to be evaluated in the loop condition). The "i" variable is not evaluated until we actually execute the anonymous method. So, how to solve this? Well, since C# has the notion of "block scope", we can actually declare a variable inside the "for" loop and it will be evaluated and "captured" in the anonymous function:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110904BS_CSharp3" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 348px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_CSharp3.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_CSharp3.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=440,width=620');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;And the output is now what we want:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110904BS_CSharp4" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 202px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_CSharp4.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_CSharp4.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=400,width=720');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;This kind of problem is very common when developing multithreaded applications. Which thread captures what, volatile and so on.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Now, in C# that was trivial. Let's look at a Javascript example that replicates this problem:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110904BS_JS1" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 202px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS1.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS1.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=400,width=600');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;As you can see, we're dynamically attaching a function to the onclick event of 10 buttons. The function attached will just show an alert with a sequential number. But just like in the C# example, we won't get a sequence of 0 to 9 alerts. Every click on every button will alert a "10" integer.&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110904BS_JS2" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 150px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS2.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS2.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=410,width=1000');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;This is where it gets tricky. Since JavaScript doesn't have the notion of "block scope", doing the same as we did in C# won't yield the expected result:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110904BS_JS3" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 207px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS3.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS3.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=360,width=640');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;This will alert "nines" ("9" because now the temporary variable won't be incremented one last time for the condition evaluation).&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110904BS_JS4" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 150px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS4.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS4.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=410,width=1000');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;To work around this issue, you can "simulate" the block scope by defining "inline functions" and executing them on the fly:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110904BS_JS5" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 249px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS5.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS5.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=410,width=620');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;In the above code, we define a function and execute it immediately, "capturing" the value of the "i" variable into another variable. This means that the "i" was evaluated when passed to the alert method that was set to the onclick event. &lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20110904BS_JS6" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 150px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS6.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/04092011/BS_JS6.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=410,width=1000');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Simple uh?&lt;/div&gt;&lt;br/&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=30" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-5083598919796364067?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/5083598919796364067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=5083598919796364067&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/5083598919796364067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/5083598919796364067'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2011/09/block-scope.html' title='Block Scope'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-2762755384958965545</id><published>2011-03-26T03:03:00.004Z</published><updated>2011-03-26T03:08:50.873Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>CLR via C# - 3rd edition On the Move</title><content type='html'>&lt;div align="justify"&gt;By now, I’ve finished all the pending reading I had and the choice for the next book to have was already made a long time ago: CLR via C# 3. I don’t know about you, but when I get a new book I feel happy. Having a paper book is a completely different story than having it in a PDF document. &lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Moving on, you might be wondering “why CLR via C#”? After all, I’ve read the CLR via C# 2.0 (more than once actually) and the .NET Framework didn’t changed that much. Well, from the CLR via C# 3 I’m not expecting a whole new world or 900pages of pure knowledge. I’m not even expecting it to be much different than the previous version. This new version of the book must (mandatory!) cover a lot of things that the 2nd version covered, and that’s fine with me. What I’m expecting is to relive a book and, on the way, find a few magic things that I’ve forgotten or others that I ignored in the previous version of the book. I even expect to find a few new magic tricks from the new version of the Framework. My expectation is that even though I’ve been working with .NET for the past 5 years, the book can still dazzle me.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;I wonder if the Asynchronous Programming Model sounds nicer in this version of the book...&lt;/div&gt;&lt;br/&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=29" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-2762755384958965545?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/2762755384958965545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=2762755384958965545&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/2762755384958965545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/2762755384958965545'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2011/03/clr-via-c-3rd-edition-on-move.html' title='CLR via C# - 3rd edition On the Move'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-8782256239941873758</id><published>2010-12-03T01:07:00.013Z</published><updated>2010-12-03T01:36:07.161Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>Configuration files xml schema?</title><content type='html'>&lt;div align="justify"&gt;Application configuration files are wonderful and particularly easy to use. In a recent project, however, I added a configuration section and some connectionstrings to an application configuration file. It looked something like this:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20101203CfgFile" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 117px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20101203/configfile.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20101203/configfile.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=300,width=800');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Nothing wrong here, the compiler doesn’t complain about anything. So, let’s run it. Then, when creating the workflow runtime, an exception was thrown:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="20101203Exception" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 205px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/20101203/wfexception.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/20101203/wfexception.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=300,width=600');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;As you can see, the exception message doesn’t say that much (nor the stacktrace or whatsoever).  After a little “googling”, I ended up in a blog post  that stated a similar problem (configuration system failed to initialize), but the error message was something like “Only one &lt;span style="font-size:10.0pt; font-family:'Courier New';color:#A31515;"&gt;&amp;lt;configSections&amp;gt;&lt;/span&gt; element allowed per config file.”. So what, I only have one. Can you guess what’s wrong?&lt;/div&gt;&lt;br/&gt;&lt;div align="justify"&gt;Well, the &lt;span style="font-size:10.0pt; font-family:'Courier New';color:#A31515;"&gt;&amp;lt;configSections&amp;gt;&lt;/span&gt; element must be the first child of the root &lt;span style="font-size:10.0pt; font-family:'Courier New';color:#A31515;"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt; element.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Thanks for the very useful exception message!&lt;/div&gt;&lt;br/&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=28" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-8782256239941873758?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/8782256239941873758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=8782256239941873758&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/8782256239941873758'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/8782256239941873758'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2010/12/configuration-files-xml-schema.html' title='Configuration files xml schema?'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-7450010217389663529</id><published>2010-01-28T20:41:00.004Z</published><updated>2010-12-03T01:30:50.831Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>ASP.NET Web Forms and ASP.NET MVC</title><content type='html'>&lt;div align="justify"&gt;I know it has been a long time since the last post, but I’ve had lots of work in the past few months. I hope I can post more often in the future. For now, I just want to leave you with a link for a post on Scott Guthrie’s blog. It contains some interesting point of views concerning the discussion around these two technologies.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Here’s the link: &lt;a href="http://weblogs.asp.net/scottgu/archive/2010/01/24/about-technical-debates-both-in-general-and-regarding-asp-net-web-forms-and-asp-net-mvc-in-particular.aspx" target="_blank"&gt;About Technical Debates&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=27" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-7450010217389663529?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/7450010217389663529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=7450010217389663529&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7450010217389663529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7450010217389663529'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2010/01/aspnet-web-forms-and-aspnet-mvc.html' title='ASP.NET Web Forms and ASP.NET MVC'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-8242250101034666922</id><published>2009-07-04T16:14:00.003+01:00</published><updated>2010-12-03T01:30:41.302Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><title type='text'>WPF vs Silverlight</title><content type='html'>&lt;div align="justify"&gt;Not too while ago, writing a web application meant you compromised yourself with all “the goods and bads” of a web environment. The same goes when writing a desktop application. The gap was quite obvious (it still is...).&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Nowadays, WPF and Silverlight have narrowed that gap and the similarities between a web application and a desktop application are increasing. But writing a desktop application using WPF doesn’t mean you have a Silverlight web application. Despite the fact that “both are XAML based platforms, there are some important functionality and implementation differences between the two”. Having this in mind, Microsoft has asked Wintellect to write a white paper about the differences between these two technologies.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;It’s interesting, here is the link: &lt;a href="http://wpfslguidance.codeplex.com" target="_blank"&gt;http://wpfslguidance.codeplex.com&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;And here’s the Wintellect post on this issue: &lt;a href="http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/06/09/comparing-and-contrasting-wpf-and-silverlight.aspx" target="_blank"&gt;John Robbins@Wintellect&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=26" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-8242250101034666922?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/8242250101034666922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=8242250101034666922&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/8242250101034666922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/8242250101034666922'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2009/07/wpf-vs-silverlight.html' title='WPF vs Silverlight'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-1794620483324470917</id><published>2009-06-18T23:07:00.005+01:00</published><updated>2010-12-03T01:30:11.038Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='books'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>CLR via C# - 3rd edition</title><content type='html'>&lt;div align="justify"&gt;A couple of months ago &lt;a href="http://cesarafonso.blogspot.com/2008/07/clr-via-c.html" target="_blank"&gt;I wrote a blog post&lt;/a&gt; about “the .NET bible”, CLR via C#. The author of the book, Jeffrey Richter, stated in his blog that he wouldn’t write a 3rd edition to cover versions 3.0 and 3.5 of the framework, but that’s about to change!&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;He wrote a blog post were he announces that he’s already writing the 3rd edition that will focus on the .NET Framework 4.0. Wonderful news! I can’t wait to put my hands on a copy of that book!&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Here’s the link: &lt;a href="http://www.wintellect.com/CS/blogs/jeffreyr/archive/2009/06/17/clr-via-c-3rd-edition.aspx" target="_blank"&gt;CLR via C#, 3rd Edition - Jeffrey Richter's Blog&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;And for those of you that haven’t read the second edition: &lt;a href="http://www.amazon.co.uk/CLR-Via-Applied-Framework-Programming/dp/0735621632/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1245362953&amp;sr=8-1" target="_blank"&gt;CLR via C#, 2nd Edition - Amazon&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=25" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-1794620483324470917?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/1794620483324470917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=1794620483324470917&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/1794620483324470917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/1794620483324470917'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2009/06/clr-via-c-3rd-edition.html' title='CLR via C# - 3rd edition'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-4197307555843155249</id><published>2009-04-02T23:32:00.007+01:00</published><updated>2009-06-07T16:14:04.710+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>Binding - "The devil is in the detail"</title><content type='html'>&lt;div align="justify"&gt;Binding is a powerful mechanism in the .NET Framework. Quoting Chris Anderson, "Binding establishes a relationship between a source and a target. In the case of object binding, the selected item for the source is determined by a property path". To bind data to CLR objects we use properties (simple CLR properties and Dependency Property-based properties).&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Take a look at the following example:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5320224470125511522" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 95px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_Ae8Ejhv17wA/SdU798MsA2I/AAAAAAAAAGU/sfKWCuVBqME/s400/bindingv1.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/02042009/bindingv1.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=240,width=800');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;In the above example I'm  binding the Text Property of the TextBox to the Content in the Button. Now, because Text is a dependency property, the above example is the same as the following:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5320224469933771986" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 95px; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/SdU797e-TNI/AAAAAAAAAGc/FqE8EOeRkIM/s400/bindingv2.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/02042009/bindingv2.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=240,width=840');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Notice that I changed the path to the “class-qualified” form of the property identifier. Both the above samples will produce the same result:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5320224470253606178" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 314px; CURSOR: hand; HEIGHT: 131px; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/SdU798rOlSI/AAAAAAAAAGk/zljCtQ0Sr7Q/s400/result.png" border="0" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;However, there's actually a big difference between them. The second example will avoid using CLR reflection to resolve the name "Text" in the binding expression because there's a “class-qualified” identifier. The first example does have a performance hit that can be avoided.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;“The devil is in the detail.”&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=23" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-4197307555843155249?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/4197307555843155249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=4197307555843155249&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/4197307555843155249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/4197307555843155249'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2009/04/binding-devil-is-in-detail.html' title='Binding - &quot;The devil is in the detail&quot;'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Ae8Ejhv17wA/SdU798MsA2I/AAAAAAAAAGU/sfKWCuVBqME/s72-c/bindingv1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-694674076366381324</id><published>2009-03-29T02:02:00.006+01:00</published><updated>2009-03-29T03:26:21.064+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WF'/><title type='text'>Workflow Foundation Bug</title><content type='html'>&lt;div align="justify"&gt;The first time I embraced the concept of a workflow was about 6 years ago, when designing &lt;a href="http://en.wikipedia.org/wiki/Algorithmic_State_Machine" target="_blank"&gt;ASM&lt;/a&gt; for microcontrolers (I miss working with the &lt;a href="http://en.wikipedia.org/wiki/MCS-51" target="_blank"&gt;MCS-51&lt;/a&gt;). So, when the WF appeared, I was pretty enthusiastic and quickly started to study and investigate this new feature of the .NET Framework. By now, I can't hide the fact that I'm a huge fan of the WF.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;But, of course, not everything is perfect and as a software product it has bugs. I came across one of them recently (related to the delay activity), here’s a little Microsoft article from the KB that describes the problem and a few other bugs.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;a href="http://support.microsoft.com/kb/932816/en-us" target="_blank"&gt;KB932816&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=22" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-694674076366381324?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/694674076366381324/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=694674076366381324&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/694674076366381324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/694674076366381324'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2009/03/workflow-foundation.html' title='Workflow Foundation Bug'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-3103010276674121632</id><published>2009-03-23T22:50:00.007Z</published><updated>2009-04-09T20:09:08.660+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VB.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>From double to int through the heap</title><content type='html'>&lt;div align="justify"&gt;Twinkling through the WCF samples that Microsoft provides, I found a line of code that captured my attention. I was organizing the samples and one of them looked interesting, so I opened it and actually found a curious line. The sample is the &lt;a href="http://msdn.microsoft.com/en-us/library/bb943471.aspx" target="_blank"&gt;WeaklyTypedJson (Ajax)&lt;/a&gt;. But let me contextualize first.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Explicit cast from an object type to an integer is valid providing that the object holds an integer.&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="Image01" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 459px; CURSOR: hand; HEIGHT: 73px; TEXT-ALIGN: center" alt="" src="http://anivwatcher.brinkster.net/blogspot/posts/23032009/Image1.png" border="0" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The above code, of course, implies one box and one unbox operation:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 360px; height: 142px;" src="http://anivwatcher.brinkster.net/blogspot/posts/23032009/Image2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5316499828066919986" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;For those VB.NET users, even automatically implicit conversion is allowed when the Strict Option is set to off:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 585px; height: 151px;" src="http://anivwatcher.brinkster.net/blogspot/posts/23032009/Image3.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5316500134868928210" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Now, when you have the code shown below, the conversion is also allowed (loosing precision):&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 232px; height: 62px;" src="http://anivwatcher.brinkster.net/blogspot/posts/23032009/Image4.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5316500138932342274" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;So, if all the above statements are true, what happens to the code bellow?&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 492px; height: 52px;" src="http://anivwatcher.brinkster.net/blogspot/posts/23032009/Image5.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5316500138137187346" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;At runtime, this will throw an InvalidCastException, stating that "Cannot unbox 'BoxedDouble' as an 'int'". This makes sense, because the CLR is trying to write in the stack a Double when the expected type is an Integer, and this violates one of the corner stones of the .NET framework, Type Safety. So, this takes us to the line of code that I found:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 443px; height: 105px;" src="http://anivwatcher.brinkster.net/blogspot/posts/23032009/Image6.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5316500146980225298" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;This is an operator overload to allow implicit conversion from JsonBaseType to Integer (InternalValue is of type object). The trick is actually quite nice: The unbox operation will be made using a double and then that double value type (on the stack) will be converted to an integer (loosing, of course, precision). Applying to my example:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 584px; height: 48px;" src="http://anivwatcher.brinkster.net/blogspot/posts/23032009/Image7.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5316500152982769522" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;And looking at the generated IL, we can see that there's an unbox operation and then a conversion:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 201px; height: 146px;" src="http://anivwatcher.brinkster.net/blogspot/posts/23032009/Image8.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5316501082826135170" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;This works fine, and it's actually a nice trick. I would write it, however, a little bit different:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 462px; height: 75px;" src="http://anivwatcher.brinkster.net/blogspot/posts/23032009/Image9.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5316501088994362754" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;But this is less explicit. Details like these is what makes the .NET Framework such a wonderful piece of software engineering.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=21" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-3103010276674121632?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/3103010276674121632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=3103010276674121632&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/3103010276674121632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/3103010276674121632'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2009/03/from-double-to-int-through-heap_23.html' title='From double to int through the heap'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-7555278444190513427</id><published>2009-01-15T21:11:00.016Z</published><updated>2009-02-15T01:16:35.454Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Export MIME Types from IIS – C#</title><content type='html'>&lt;div align="justify"&gt;Last month &lt;a href="http://cesarafonso.blogspot.com/2008/12/export-mime-types-from-iis_06.html" target="_blank"&gt;I wrote a post&lt;/a&gt; on how to export MIME Types from IIS. I also provided a little gadget to “do the job”. That tool was written in VBScript. However, I’ve received a couple of e-mails asking me how the same task could be accomplished using just C#. Well, it’s actually quite simple, &lt;a href="http://anivwatcher.brinkster.net/blogspot/posts/15012009/IISProp.zip" target="_blank"&gt;here’s the CS file&lt;/a&gt; with the code.&lt;/div&gt;&lt;br/&gt;&lt;div align="justify"&gt;You only need to add two references to the project were you add this file:&lt;/div&gt;&lt;div align="justify"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;– System.DirectoryServices;&lt;/div&gt;&lt;div align="justify"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;– Active DS IIS Namespace provider (needed in order to use the IISOle provider). This is in the COM tab on the Add Reference dialog.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;That’s it. The call to the function in the CS file should look something like:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 445px; height: 49px;" src="http://anivwatcher.brinkster.net/blogspot/posts/15012009/iisprop.png" border="0" alt="" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Those of you who asked for this CS file, please give some feedback. This is for .NET Framework 3.5 (and above, obviously).&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=20" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-7555278444190513427?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/7555278444190513427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=7555278444190513427&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7555278444190513427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7555278444190513427'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2009/01/export-mime-types-from-iis-c.html' title='Export MIME Types from IIS – C#'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-7915825682787952664</id><published>2009-01-12T19:08:00.006Z</published><updated>2009-02-15T01:16:22.636Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>SQL CLR - Assembly.Load()</title><content type='html'>&lt;div align="justify"&gt;The jump from SQL Server 2000 to SQL Server 2005 was huge at all levels (fortunately, I didn’t got the chance to work with previous versions of the SQL Server). One of the many features introduced with SQL Server 2005 was the SQL CLR. The idea is to allow managed code to be hosted by and executed in the Microsoft SQL Server environment.Translating, you can write your stored procedures, user defined functions, trigger and so on in any CLS compliant language and use them in any standard SQL statement as if they were created using T-SQL. You can even define new types and they will be recognized in SQL.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Now, accordingly to Microsoft, the SQL Server itself hosts the .NET Framework runtime (resources management and so on are no longer satisfied by the undererlying OS). So, one other question arises: under what security permissions does it run? &lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Quoting Microsoft, "The CLR supports a security model called &lt;a href="http://msdn.microsoft.com/en-us/library/930b76w0(VS.71).aspx" target="_blank"&gt;Code Access Security (CAS)&lt;/a&gt; for managed code. In this model, permissions are granted to assemblies based on the identity of the code (e.g.: signed assemblies), as opposed to the identity of the user or process running the code." When moving to a &lt;a href="http://msdn.microsoft.com/en-us/library/ms131047.aspx" target="_blank"&gt;CLR hosted environment&lt;/a&gt; however, this implies that "the ability to generate managed code dynamically is not supported inside the &lt;a href="http://msdn.microsoft.com/en-us/library/ms345101.aspx" target="_blank"&gt;CLR hosted environment in SQL Server&lt;/a&gt;. Such code would not have the CAS permissions to run and would therefore fail at run time."&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;So, translating Microsofts’ fancy words: what happens when dynamically loading an assembly? Bum...&lt;/div&gt;&lt;div align="justify"&gt;Loading an assembly — either explicitly by calling the System.Reflection.Assembly.Load() method or implicitly through the use of Reflection.Emit namespace — is not permitted. Dynamic assembly loading is always disallowed under SQL CLR, even using UNSAFE permissions. If your assembly uses any of these features, the DMBS will yield an error message when running the code:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 109px;" src="http://2.bp.blogspot.com/_Ae8Ejhv17wA/SWvEhxaRkVI/AAAAAAAAAEo/Ksv8m2MFEqM/s400/caspermissions.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5290538271755047250" onclick="window.open('http://2.bp.blogspot.com/_Ae8Ejhv17wA/SWvEhxaRkVI/AAAAAAAAAEo/Ksv8m2MFEqM/s1600-h/caspermissions.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=400,width=1000');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;This isn't a big issue, though. Mainly because the Database is one of the most important components of any system and you'll want it to be as "well defined" and secure as possible.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=19" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-7915825682787952664?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/7915825682787952664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=7915825682787952664&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7915825682787952664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7915825682787952664'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2009/01/jump-from-sql-server-2000-to-sql-server_12.html' title='SQL CLR - Assembly.Load()'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Ae8Ejhv17wA/SWvEhxaRkVI/AAAAAAAAAEo/Ksv8m2MFEqM/s72-c/caspermissions.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-6186186702240986001</id><published>2009-01-06T21:18:00.009Z</published><updated>2009-06-07T16:14:21.251+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WF'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>The ParallelActivity</title><content type='html'>&lt;div align="justify"&gt;As I mentioned before, writing high-performance, multithread, extensible, expansible and scalable software is actually very challenging. Hardware improvements can be worthless unless you know how to take advantage of them.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Now, talking about multithreading, WF has a composite &lt;a href="http://msdn.microsoft.com/en-us/library/system.workflow.activities.parallelactivity.aspx" target="_blank"&gt;activity that can execute child activities in parallel&lt;/a&gt; (at least, in theory). The idea is that branches execute in a “parallel fashion”:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5288295923120894466" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 393px; CURSOR: hand; HEIGHT: 400px; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/SWPNH5zEcgI/AAAAAAAAAEg/WYkwf8o8CSo/s400/parallelactivity.png" border="0" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The first thing to note is that the order in which child activities execute is non-deterministic. That is, it’s not guaranteed that all the activities in the first branch get executed before the second branch gets executed. It’s not guaranteed that the WF runtime will execute the first activity of each branch, then the second and so on. The only guarantee is that a “branch switch” won’t happen until a single activity is finished (e.g.: if you have a code activity, there won’t be a “branch switch” until the thread finishes processing all the code in the activity).&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;“So far so good”.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Moving on, whenever we talk about “parallel execution”, we always think of execution in a multithreaded sense. This isn’t truly the case. The WF runtime uses only a single thread from the threadpool to run all the branches. This means that the parallel execution paths do not execute concurrently, and what we have here is actually &lt;a href="http://en.wikipedia.org/wiki/Thread_(computer_science)" target="_blank"&gt;cooperative multithreading&lt;/a&gt;. The question is: why use only one thread? I mean, why can’t we specify that one branch should run in one thread and all the others in another? Imagine that we have an activity in one of the branches that will actually take a long time, for instance, a web request?&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Looking to the basics of WF, doing what I’m suggesting will actually “break” the idea of an Activity as the basic unit of work. What I’m suggesting will allow a “branch switch” in the middle of activities execution. A code activity might be interrupted due to a context switch.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;I think, though, that this would be a nice feature.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Nevertheless, you can “do it yourself”: asynchronous programming model, threadpool...&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=18" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-6186186702240986001?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/6186186702240986001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=6186186702240986001&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/6186186702240986001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/6186186702240986001'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2009/01/parallelactivity.html' title='The ParallelActivity'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Ae8Ejhv17wA/SWPNH5zEcgI/AAAAAAAAAEg/WYkwf8o8CSo/s72-c/parallelactivity.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-5264301303573212611</id><published>2008-12-11T00:53:00.007Z</published><updated>2009-02-15T01:15:56.598Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><title type='text'>Silverlight – Under the covers</title><content type='html'>&lt;div align="justify"&gt;About 6 months ago, &lt;a href="http://cesarafonso.blogspot.com/2008/07/essential-wpf-summer-reading.html" target="_blank"&gt;I “blogged”&lt;/a&gt; about the book that I had chosen as my summer reading - &lt;a href="http://www.amazon.co.uk/Essential-Presentation-Foundation-Microsoft-Development/dp/0321374479/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1228957104&amp;sr=8-1" target="_blank"&gt;Essential WPF&lt;/a&gt;. Due to some personal problems, however, I was unable to complete my task before the summer end. But “I'm catching up” and I'm half the way with eating Chris Andersons’ words. I must say that the book hasn't convinced me yet, but I'll leave that thought on hold until I'm finished reading it. Nevertheless, every technical book has that little bag of knowledge that can surprise you.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Essential WPF actually answered my biggest question around Silverlight: How on earth does it work? What runs where? Under what security permissions?&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Well, WPF hosts applications by implementing an ActiveX DocObject (OLE DocObject). This means that every application that supports hosting DocObjects can actually host WPF applications. To know how to interpret the XBAP extension, when the .NET Framework is installed, a mime handler is registered for the XBAP extension, which loads up WPF. "The real deal" comes next. WPF runs all browser-hosted applications out of process, using a host application called PresentationHost. This isn't what I expected and actually takes me to the answer to one of the questions made above: If it's running "out of the browsers' scope", under what security permissions is it running? The answer is simple: Quoting Chris Anderson, "on Windows XP, PresentationHost.exe is launched with modified NT permissions. The admin token of whatever permission “iexplore.exe” is running is used to set the security permissions. On Windows Vista, the Limited User Access feature provides this same type of security model.”&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;This is quite intriguing and has brought a few more questions to my head, especially concerning on what’s going on “under the covers”. But let me solve them by myself first and I will post back later. &lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The Silverlight world is new to me, I wonder if it will amaze me as much as the WF did for the last year.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=17" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-5264301303573212611?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/5264301303573212611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=5264301303573212611&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/5264301303573212611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/5264301303573212611'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/12/silverlight-under-covers.html' title='Silverlight – Under the covers'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-6779861948376110105</id><published>2008-12-06T11:39:00.007Z</published><updated>2011-11-25T10:20:14.009Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><title type='text'>Export MIME Types from IIS</title><content type='html'>&lt;div align="justify"&gt;I know that my latest posts are slightly “off-topic” from my passion, the .NET Framework, but I’ve been working with other products that can still tickle my brain.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Now, I usually don’t share “my homework” or “personal developments”, but this might actually be useful at work for some of you. It’s quite simple: the idea is to export all the MIME Types registered in IIS. Furthermore, you can generate an HTML page (with style sheet) from the exported MIME Types. The instructions are in the ZIP provided below. The package contains 4 files:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1 – &lt;b&gt;MIMETypesVBScript.vbs&lt;/b&gt;: the VBScript that will get the MIME Types from IIS. Note that if you are using the script on a remote server (through remote desktop, VPN, whatever), you might need special permissions to execute it.&lt;/div&gt;&lt;div align="justify"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;2 – &lt;b&gt;MIMETypesXSL.exe&lt;/b&gt;: the executable that will perform the XSL transformation to generate the final “styled” HTML page.&lt;/div&gt;&lt;div align="justify"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3 – &lt;b&gt;MIMETypes.XSL&lt;/b&gt;: The file that will apply the style. Feel free to develop your own.&lt;/div&gt;&lt;div align="justify"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4 – &lt;b&gt;Readme.txt&lt;/b&gt;: Instructions on “how to get things working”.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;As I said, the instructions are in the Readme file. I know it isn’t a perfect method, but it was the quickest I could remember. You can download the ZIP file &lt;a href="http://anivwatcher.brinkster.net/blogspot/posts/04122008/MIMETypes.zip" target="_blank"&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Update: &lt;a href="http://cesarafonso.blogspot.com/2009/01/export-mime-types-from-iis-c.html" target="_blank"&gt;How to do the same with C#&lt;/a&gt;?&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=16" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-6779861948376110105?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/6779861948376110105/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=6779861948376110105&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/6779861948376110105'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/6779861948376110105'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/12/export-mime-types-from-iis_06.html' title='Export MIME Types from IIS'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-4489598333320346399</id><published>2008-12-04T19:19:00.013Z</published><updated>2009-02-15T01:15:15.366Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='SyBase'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Scary – SyBase</title><content type='html'>&lt;div align="justify"&gt;In my opinion, SQL Server is the most complete DBMS. For the past couple of years, I've worked with it from the basic T-SQL to the most administrative clustering, security and so on.&lt;/div&gt;&lt;div align="justify"&gt;But despite my preferences (Microsoft), it's always good to keep your mind open to other solutions around you. For instance, I also appreciate MySQL, which is a great solution for small business (free).&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The last month, however, I've worked with SyBase. SyBase is known by many people as being the "cousin" of SQL Server for historical reasons. Of course, the syntax isn't much different from SQL Server, but the tiniest difference can have a big impact. Take the following example of a stored procedure in SQL Server:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5276018140632529186" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 295px; CURSOR: hand; HEIGHT: 152px; TEXT-ALIGN: center" alt="Stored Procedure" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/STgui5zrOSI/AAAAAAAAAD4/SpQ5gMnAidM/s400/SQLStored.png" border="0" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;You can call this procedure passing no parameters or one:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5276018144916276530" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 219px; CURSOR: hand; HEIGHT: 45px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_Ae8Ejhv17wA/STgujJxABTI/AAAAAAAAAEA/GQK_xjiaEeY/s400/SQLStoredCall.png" border="0" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;And that's it. If you pass more than one parameter, the SQL Server Management Studio will yield an error message:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;span style="color:red; font-family:Arial; font-size:12px;"&gt;Msg 8144, Level 16, State 2, Procedure DefaultParameter, Line 0&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="color:red; font-family:Arial; font-size:12px;"&gt;Procedure or function DefaultParameter has too many arguments specified.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Now, the same procedure can be written for SyBase... exactly the same! However, in SyBase, you can call the procedure with "n" arguments:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5276018441304378162" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 388px; CURSOR: hand; HEIGHT: 68px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_Ae8Ejhv17wA/STgu0Z5bizI/AAAAAAAAAEQ/EflueSi0Ue8/s400/SyBaseStoredCall.png" border="0" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The DBMS will take just the number of arguments that the procedure wants, ignoring the rest of them. This is quite odd!&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The problem I had at work was that someone created a procedure with 2 parameters, both varchar. Then, all the other stored procedures were written to call this procedure with two varchar parameters. Somewhere in time, the second parameter was no longer required and was removed from the procedure definition. Of course, the code that called this procedure kept running because SyBase allows the procedure to request just one parameter and the caller to pass two parameters.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;My task was to add a new output parameter to the procedure. It now had 2 parameters again, but the one I added was of type integer. Can you imagine what happened to all the calls to the procedure? Bum! They where passing two varchar variables and now the procedure is expecting one varchar and one integer. Scary...&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;I haven't searched for an explanation for this behaviour (nor I'm going to) because I'm sure it won’t convince me. So, that's one point less to the SQL Server cousin.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=15" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-4489598333320346399?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/4489598333320346399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=4489598333320346399&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/4489598333320346399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/4489598333320346399'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/12/scary-sybase.html' title='Scary – SyBase'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Ae8Ejhv17wA/STgui5zrOSI/AAAAAAAAAD4/SpQ5gMnAidM/s72-c/SQLStored.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-3916612201336667154</id><published>2008-11-23T19:38:00.008Z</published><updated>2009-02-15T01:15:02.589Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>PHP and .NET</title><content type='html'>&lt;div align="justify"&gt;Outside of the “Microsoft’s world”, there are few technologies and programming languages that I enjoy. &lt;a href="http://www.php.net/" target="_blank"&gt;PHP&lt;/a&gt; is definitely on that small group.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Up until now, the only way to load a .NET assembly into PHP and use its types, functions and so on, was to use COM objects. Now, the PHP team is actually developing functions to load a .NET assembly directly without using COM objects (at least, not in code). It has been in testing for quite a while, here’s the link:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;a href="http://www.php.net/manual/en/ref.dotnet.php" target="_blank"&gt;http://www.php.net/manual/en/ref.dotnet.php&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=14" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-3916612201336667154?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/3916612201336667154/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=3916612201336667154&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/3916612201336667154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/3916612201336667154'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/11/php-and-net.html' title='PHP and .NET'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-3542054961342330025</id><published>2008-11-20T01:34:00.007Z</published><updated>2009-02-15T01:14:41.945Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>LINQ - Just because you can</title><content type='html'>&lt;div align="justify"&gt;Day after day, the .NET Framework evolves in a fantastic way and if you know how to take advantage of the new features, your productivity can actually improve. However, if you don’t have the knowledge, you will do rude mistakes. The latest I encountered was something like this (adapted to the widely used person example and reduced to fit the blogpost):&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;img id="BLOGGER_PHOTO_ID_5270547275047869698" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 354px; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_Ae8Ejhv17wA/SSS-0nUhnQI/AAAAAAAAADo/2eRKP4Znhyw/s400/LINQ.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/19112008/LINQ.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=660,width=660');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The idea was to search a collection (in this case, a Person’s collection) and print out the items that did match a certain condition (in the above example, Person’s whose age is over 18). So far so good, the output is what was expected. But the programmer decided that would be “cool” to write it using LINQ. Can you identify the problem on the above example?&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Well, as you might expect, the “Where” extension doesn’t actually perform as “an SQL where clause”. The “Where” extension translates in a foreach statement:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;img id="BLOGGER_PHOTO_ID_5270547381083240018" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 88px; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_Ae8Ejhv17wA/SSS-6yVU9lI/AAAAAAAAADw/B0FmeuDFPxs/s400/where.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/19112008/where.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=260,width=860');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;So, in the above example, first the user iterates through the collection to find the items that match the condition and then iterates through those items to print them. Two foreach statements, something that could be done with one foreach and one if clause… And that’s not all, but it’s enough to make my point of view.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;I know this is a “way too basic” example, but the point is that tools shouldn’t be used “just because you can” or “they’re cool”. LINQ is useful in a wide number of scenarios but not on every task you have.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=13" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-3542054961342330025?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/3542054961342330025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=3542054961342330025&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/3542054961342330025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/3542054961342330025'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/11/linq-just-because-you-can.html' title='LINQ - Just because you can'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Ae8Ejhv17wA/SSS-0nUhnQI/AAAAAAAAADo/2eRKP4Znhyw/s72-c/LINQ.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-380664679770319544</id><published>2008-11-06T19:28:00.003Z</published><updated>2009-02-15T01:14:24.543Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Optional Parameters (C#)</title><content type='html'>&lt;div align="justify"&gt;“Yes”! This was the word out of my mouth when reading about the new C# 4.0 that will be coming soon. Why? Well, a couple of months ago &lt;a href="http://cesarafonso.blogspot.com/2008/06/vbnet-optional-parameters.html" target="_blank"&gt;I wrote a post&lt;/a&gt; about optional parameters in VB.NET and how useful they can be. I also questioned why the C# team didn’t implement this feature. My answer is here (quoting a white paper from the C# team):&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;b&gt;Named and optional parameters&lt;/b&gt;&lt;/div&gt;&lt;div align="justify"&gt;“Parameters in C# can now be specified as optional by providing a default value for them in a member declaration. When the member is invoked, optional arguments can be omitted. Furthermore, any argument can be passed by parameter name instead of position.”&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;And the same white paper goes on justifying this new feature much the way I did on my blog post:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;b&gt;COM specific interop features&lt;/b&gt;&lt;/div&gt;&lt;div align="justify"&gt;“Dynamic lookup as well as named and optional parameters both help making programming against COM less painful than today. On top of that, however, we are adding a number of other small features that further improve the interop experience.”&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;They’ve taken the “optional parameter” idea even further and introduced Named Parameters.&lt;/div&gt;&lt;div align="justify"&gt;Day after day, the .NET world keeps on surprising me. &lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=12" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-380664679770319544?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/380664679770319544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=380664679770319544&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/380664679770319544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/380664679770319544'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/11/optional-parameters-c.html' title='Optional Parameters (C#)'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-7045999247034808449</id><published>2008-10-09T23:30:00.007+01:00</published><updated>2009-02-15T01:14:07.877Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='WF'/><title type='text'>Why compensatable transactions?</title><content type='html'>&lt;div align="justify"&gt;Last month, I wrote a &lt;a href="http://cesarafonso.blogspot.com/2008/08/compensated-transactions.html" target="_blank"&gt;post&lt;/a&gt; about compensatable transactions, but left a question in the air: how really useful can this kind of transactions be and where to apply it?&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Well, when reading &lt;a href="http://www.amazon.co.uk/Microsoft-Windows-Workflow-Foundation-Step/dp/073562335X/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1223591723&amp;sr=8-1" target="_blank"&gt;Kenn Scribner’s book about WF&lt;/a&gt;, I didn’t catch the “big picture”. XA-style transactions seemed enough. But after reading a couple of articles from the WF Team at the MSDN magazine, I understood what &lt;a href="http://www.wintellect.com/TechnicalBioDetail.aspx?Tech=6" target="_blank"&gt;Kenn Scribner&lt;/a&gt; was talking about in the book.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Here’s an example from me that better describes his thoughts (although not far from his example). Keep in mind that depending on the isolation level you choose for a XA-style transaction data may became locked throughout the entire transaction scope.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Imagine that you have to develop an intranet for a company with several departments, all of them with the ability to place orders for material specific to their business area. Of course, all the orders must be approved by the accounts man before sent to the suppliers and paid. Would you use a XA-style transaction throughout the process? What if the accounts man takes hours (or days!) to approve the order, should the data be locked for that period? Further more, if an exception happens, should we roll back and some orders where miraculously never placed or never shipped to the supplier? What happens to transactional tasks in the context of a larger process where you can’t lock data for too long and must be able to roll back past commits?&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;This is much the example he gave. In a long running process, you might have to split one action that you would desire to be atomic, breaking one of the ACID properties: atomicity. The idea was that from the time the employee places the order until the order actually gets to the supplier and paid, it’s all or nothing.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Compensatable transactions allow this scenario. Quoting &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163411.aspx" target="_blank"&gt;Dino Esposito at MSDN magazine&lt;/a&gt;, “compensation is any logic you run at some point to undo, mitigate, or compensate for the effects of previous operations. The point is that the compensatable transaction might contain child ACID transactions that, once committed, can’t be rolled back any longer. However, in case of a further failure, their effects must be compensated for in some way. Compensation is like rollback except that the developer is called to write any code used to compensate for the work done.”&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Dino Esposito actually goes on and answers my question: why bother with compensation? “When different companies and services are involved, defining the process in terms of the ACID semantics is often challenging. For it to be isolated and durable, you have to keep all resources of different companies locked for the duration of the task. This is frequently unreasonable, especially if the task is long.”&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;After all this talk, let’s resume: although the idea behind both the transaction types I’ve mentioned is the same, they’re actually quite different. Obviously, you want your XA-style transactions to be as short as possible for a variety of reasons (most important, data might get locked) while in a compensatable scenario this isn’t true.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Although I haven’t used it yet (nor I’m expecting to), it’s a great thing that WF incorporates this concept.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=11" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-7045999247034808449?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/7045999247034808449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=7045999247034808449&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7045999247034808449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7045999247034808449'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/10/why-compensatable-transactions.html' title='Why compensatable transactions?'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-7988771552619121302</id><published>2008-09-12T22:13:00.018+01:00</published><updated>2009-02-15T01:13:55.324Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='VB.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>Add.Ovf</title><content type='html'>&lt;div align="justify"&gt;Writing high-performance applications is probably one of the most enthusiastic challenges a software developer can face. Nowadays, developing an application isn’t as hard as it was 10 years ago, mostly due to the appearance of managed environments (and tools improvement). But writing high-performance, multithread, extensible, expansible and scalable software is actually very challenging. Every detail counts.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Having said that, there’s one detail I haven’t paid much attention in the past: compiler flags (the other guidelines to write such software certainly can’t be learned from a blog). When using Visual Studio, creating a project, building and deploying it is very easy. But when building the project, the IDE actually uses a command line to build the project (for C#, “csc.exe”, for VB.NET “vbc.exe”) passing some parameters while others are default. Well, by default, the VB.NET compiler generates overflow checks for integer operations (both Debug and Release versions). The C# compiler doesn’t – you must specify that you want integer overflow checks (“csc.exe /checked” or in the properties of your Visual Studio project).&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;What is integer overflow check? An example from Derek Hatchard and Scott Swigart at MSDN:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;img id="BLOGGER_PHOTO_ID_5245246189821823986" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_Ae8Ejhv17wA/SMrbnn_NC_I/AAAAAAAAAC4/8Oy82zAj6NU/s400/msdnexample.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/12092008/msdnexample.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=600,width=1124');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Quoting their explanation: “The code segments look equivalent (the extra C# variable loopLimit is used to match Visual Basic .NET behaviour, which is to copy max to a temporary local variable). Both methods require two integer addition operations – one for the increment of the sum variable and one for the increment of the loop counter. By default, the Visual Basic .NET compiler will generate the IL instruction add.ovf for these addition operations. The add.ovf instruction includes an overflow check and throws an exception if the sum exceeds the capacity of the target data type. By contrast, the default output of the C# compiler is the IL instruction add, which does not include an overflow check.”&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Looking at the generated IL by both the compilers we can see the difference:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;img id="BLOGGER_PHOTO_ID_5245246456224627778" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_Ae8Ejhv17wA/SMrb3IalPEI/AAAAAAAAADA/s4JDCkk0kSw/s400/csharpil.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/12092008/csharpil.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=600,width=800');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5245247186652554370" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/SMrchpeK5II/AAAAAAAAADQ/h4eTdo82Iwc/s400/vbdotnetil.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/12092008/vbdotnetil.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=600,width=800');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;How about running the examples to compare the performance?&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;img id="BLOGGER_PHOTO_ID_5245247350832425122" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/SMrcrNFs6KI/AAAAAAAAADY/cHMaqR1VMRA/s400/runned.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/12092008/runned.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=300,width=800');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;As you can see when using integer overflow check there’s a big difference. If you set the VB compiler not to generate integer overflow checks the above VB.NET code will have the same performance as the C# version. You must be aware of details like these in order to “sharp” your application’s performance – and don’t say “I’m using C#” because that’s not the point!&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Just as a final note, you can also force integer overflow checks for some operations using the C# keyword “checked”: &lt;a href="http://msdn.microsoft.com/en-us/library/74b4xzyw.aspx" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/74b4xzyw.aspx&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=10" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-7988771552619121302?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/7988771552619121302/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=7988771552619121302&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7988771552619121302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7988771552619121302'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/09/addovf.html' title='Add.Ovf'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_Ae8Ejhv17wA/SMrbnn_NC_I/AAAAAAAAAC4/8Oy82zAj6NU/s72-c/msdnexample.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-6534430957766640084</id><published>2008-08-29T14:30:00.007+01:00</published><updated>2009-02-15T01:13:10.327Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='WF'/><title type='text'>Compensatable transactions</title><content type='html'>&lt;div align="justify"&gt;Up until now, when working with SQL Server, the most common transaction type I’ve used was the XA-style transaction. An XA transaction involves the XA protocol, which implements the &lt;a href="http://en.wikipedia.org/wiki/Two-phase_commit_protocol" target="_blank"&gt;two-phase commit&lt;/a&gt; (you’re probably familiar with this, most DBMS use it, but if you aren’t I suggest you go ahead and work on this issue, since it is essential when working with databases). The XA transactions, when using non-volatile resources, guarantees the ACID properties (Atomicity, Consistency, Isolation and Durability). This is all done at the DBMS level.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;However, Windows Workflow Foundation “translates” this idea into an activity: the TransactionScope activity. What this means is that the activity knows how to use this kind of transactions without forcing the programmer to explicitly open a transaction. You just place activities inside the TransactionScope activity and that’s a XA-style transaction. You can even define the isolation level of the transaction for that activity (Serializable, Read Uncommitted, Repeatable Read and so on).&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;But WF also has another transaction style: The compensatable transactions. I wasn’t aware of this type of transactions up until now. The idea is basically the same as in XA-style transactions: if something goes wrong in one of the operations performed in the scope of the transaction, the data must go to a consistent state. But there’s a difference: When using XA-style transactions, if something fails, the transaction is “rolled back”. When using compensation, if something does fail, the transaction isn’t automatically “rolled back”. Instead, you must provide the actions to compensate the failure. To better explain, let me use the example given by  &lt;a href="http://www.wintellect.com/TechnicalBioDetail.aspx?Tech=6" target="_blank"&gt;Kenn Scribner&lt;/a&gt;: “If I give you five apples using a XA-style transaction and the transaction fails, time itself rewinds to the point I started to give you the apples. In a sense, history is rewritten such that the five apples were never given in the first place. But if I give you five apples in a compensated transaction and the transaction fails, to compensate (so that we maintain a determinate application state), you must return five apples to me.”&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;What this means is that the programmer is responsible for compensating, providing the actions to compensate the failed transaction. There is no “rollback”. Is this better than XA-style transactions? Well, it certainly gives you more control (and responsibility), but you must be very careful when writing compensation actions. The smallest mistake can leave a database in an inconsistent state.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;I haven’t used this transaction style yet, but Kenn Scribner gives a hint on a few scenarios where it could be more useful then the XA-style transactions. I’m going to analyze these scenarios more deeply in order to see if it really makes sense.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=9" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-6534430957766640084?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/6534430957766640084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=6534430957766640084&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/6534430957766640084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/6534430957766640084'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/08/compensated-transactions.html' title='Compensatable transactions'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-7389865369264394118</id><published>2008-08-20T14:46:00.005+01:00</published><updated>2009-02-15T01:12:54.633Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='WF'/><title type='text'>WorkflowRuntime object</title><content type='html'>&lt;div align="justify"&gt;On chapter 1 of the book &lt;a href="http://www.amazon.co.uk/Microsoft-Windows-Workflow-Foundation-Step/dp/073562335X/ref=sr_1_3?ie=UTF8&amp;s=books&amp;qid=1219240645&amp;sr=8-3" target="_blank"&gt;Windows Workflow Foundation Step by Step&lt;/a&gt;, the author states that “there can be only a single instance of the WorkflowRuntime per AppDomain”. When I was reading the book, I didn’t found this odd because it makes some sense. You only need one runtime.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;In a recent project, however, I was presented with a scenario where I needed a different behaviour from the WorkflowRuntime when using multiple workflows. Simply put, I had 3 different workflows in the same AppDomain and I wanted the WorkflowRuntime to persist one of them and not the others. The only logical way to accomplish this behaviour was to implement myself a persistence service. Of course, I could also create another AppDomain and run another WorkflowRuntime in the new AppDomain but I don’t like this “workaround”.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Since I was short on time, after I googled a little I found that you can have more than one WorkflowRuntime per AppDomain. And this helped. Two WorklflowRuntime objects, one using the persistence service and the other one not using it. Yes, this leads to more resources consumption (the WorkflowRuntime isn’t a “cheap” object) but it was the quickest solution and I wasn’t concerned with performance.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Despite this “multiple WorkflowRuntime objects per AppDomain” feature, I still agree with the author of the book (Kenn Scribner) when he states that we should use a WorkflowRuntime Factory (Singleton and Factory patterns).&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Here’s the errata page for the book: &lt;a href="http://www.endurasoft.com/wf.aspx" target="_blank"&gt;http://www.endurasoft.com/wf.aspx&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=8" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-7389865369264394118?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/7389865369264394118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=7389865369264394118&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7389865369264394118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7389865369264394118'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/08/workflowruntime-object.html' title='WorkflowRuntime object'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-7181396947677381395</id><published>2008-07-21T22:42:00.003+01:00</published><updated>2009-02-15T01:12:16.048Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='books'/><title type='text'>Essential WPF - Summer reading</title><content type='html'>&lt;div align="justify"&gt;I’m 15 days away from my summer vacations and my “summer reading” has arrived! &lt;a href="http://www.amazon.co.uk/Essential-Presentation-Foundation-Microsoft-Development/dp/0321374479/ref=sr_1_6?ie=UTF8&amp;s=books&amp;qid=1216667787&amp;sr=8-6" target="_blank"&gt;Essential Windows Presentation Foundation&lt;/a&gt; is the chosen one! My main goal is to get a solid base before moving to Silverlight. I think Silverlight is the true meaning of WPF.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;In the past couple of months, my “free time” reading has been Windows Workflow Foundation, step by step (by Kenn Scribner). Good book, I’m still finishing it. I just hope that this Essential WPF is at least as good.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=7" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-7181396947677381395?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/7181396947677381395/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=7181396947677381395&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7181396947677381395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/7181396947677381395'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/07/essential-wpf-summer-reading.html' title='Essential WPF - Summer reading'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-6851741843207418532</id><published>2008-07-21T21:41:00.020+01:00</published><updated>2009-06-07T16:14:49.630+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>Extension Methods - Cool</title><content type='html'>&lt;div align="justify"&gt;Since the first release of the .NET Framework (2002), Microsoft as significantly improved the quality and features of the framework. Also, the compilers and the Visual Studio have evolved in a fantastic way.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;One of the many features introduced in VS2008 (with the new compilers) was the Extension Methods. What are they? A cute little thing! Ok, technically speaking, I prefer to quote Scott Gu:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;“Extension methods allow developers to add new methods to the public contract of an existing CLR type, without having to sub-class it or recompile the original type. Extension Methods help blend the flexibility of “duck typing” support popular within dynamic languages today with the performance and compile-time validation of strongly-typed languages. Extension Methods enable a variety of useful scenarios, and help make possible the really powerful LINQ query framework that is being introduced with .NET as part of the “Orcas” release.”&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;But what’s happening behind the scene? Is this complicated? Well, lets start by looking at the extension methods with one example from Scott Gu. Have you ever wanted to check if a string is in some way valid? For example, have you ever wanted to check if a string is a valid e-mail address or “postal code”? Before extension methods, you’d probably write something like this:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5225572069358447778" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_Ae8Ejhv17wA/SIT2HF5QLKI/AAAAAAAAACY/wVZkZKmbpww/s400/csharp-noextension.png" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/21072008/csharp-noextension.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=600,width=820');" border="0" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;As you can see, there’s a static class with static methods to validate the string, which is passed as a parameter. But we’re trying to check if a string is in some way valid, so, shouldn’t we have this capability on the string type? Well, this is Extension Methods. Here’s the version using extension methods:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5225572661920405330" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_Ae8Ejhv17wA/SIT2plXCF1I/AAAAAAAAACg/AtBMpQJoeek/s400/csharp-extension.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/21072008/csharp-extension.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=600,width=820');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Cool! You actually call a method from the string type! The “this” keyword tells the compiler that the extension method is to be applied to string type. However, what’s happening behind the scenes? Well, if we compile both the examples we will notice that it’s the C# compiler that’s “doing the trick”. Here’s the IL for the first example:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5225572828309943826" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_Ae8Ejhv17wA/SIT2zRNY9hI/AAAAAAAAACo/Jw087NJnf9w/s400/csharp-noextensionil.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/21072008/csharp-noextensionil.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=580,width=840');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;And here’s the IL for the second example using extension methods:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5225572970340347090" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/SIT27iUE7NI/AAAAAAAAACw/U1YQN2XeDYU/s400/csharp-extensionil.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/21072008/csharp-extensionil.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=580,width=860');" /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;As you may have noticed, the compiler actually transformed the extension method in a normal method call, generating a class. From the CLR point of view, everything is still the same (there’s one new flag).&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="justify"&gt;This is “the big picture”. However, the extension methods can be used with every base class or interface. Basically, it can be applied to any type. And this is fantastic. The built-in LINQ Extension methods use this feature. Once you get used to some of these “syntactical sugar” improvements, you’ll get addicted.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;There are so much new cool features with the new compilers that come with VS2008 that the best is to take a look at Scott Gus’ blog. Despite the fact that he normally doesn’t look at the generated IL, he discusses important issues and his speech is very easy to understand. It’s a fantastic source of information.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=6" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-6851741843207418532?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/6851741843207418532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=6851741843207418532&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/6851741843207418532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/6851741843207418532'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/07/extension-methods-cool.html' title='Extension Methods - Cool'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Ae8Ejhv17wA/SIT2HF5QLKI/AAAAAAAAACY/wVZkZKmbpww/s72-c/csharp-noextension.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-2706633122528593467</id><published>2008-07-16T01:28:00.004+01:00</published><updated>2009-02-15T01:09:02.640Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='CLR'/><title type='text'>Memory Leaks</title><content type='html'>&lt;div align="justify"&gt;The .NET Framework evolves considerably from version to version. I think it’s the best software Microsoft has ever written and documented. The latest versions of the framework (and the compilers) are truly brilliant.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;But not everyone works with the latest version. Some companies, for their own reasons, often work with older versions, some of them even with version 1.1. That was the case of some projects in my last job.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;This introduction is just to contextualize why I’m talking about a “so old” version of the Framework. Remember the memory leaks in C++, when there was no Garbage Colector? Well, here’s one in .NET 1.x:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;a href="http://support.microsoft.com/kb/555925/en-us" target="_blank"&gt;http://support.microsoft.com/kb/555925/en-us&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Tip: Upgrade! Always try to work with the latest version of the .NET Framework.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=5" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-2706633122528593467?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/2706633122528593467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=2706633122528593467&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/2706633122528593467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/2706633122528593467'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/07/why-work-with-latest-version-of-net.html' title='Memory Leaks'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-1148816987120951950</id><published>2008-07-04T02:08:00.007+01:00</published><updated>2009-02-15T01:10:40.822Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='books'/><title type='text'>CLR via C#</title><content type='html'>&lt;div align="justify"&gt;First of all, there’s something everyone reading this blog should have already read: The .NET Bible! I’m talking about the &lt;a href="http://www.amazon.co.uk/CLR-Via-Applied-Framework-Programming/dp/0735621632/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1215133786&amp;amp;sr=8-1" target="_blank"&gt;CLR via C# 2.0&lt;/a&gt;, written by Jeffrey Richter, a Co-Founder of &lt;a href="http://www.wintellect.com/" target="_blank"&gt;Wintellect&lt;/a&gt;. If you want to be a good .NET developer, you must read this book.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="justify"&gt;The last version of the book targeted the .NET Framework 2.0. Since then, Microsoft has released versions 3.0 and 3.5 of the Framework. The book, however, won’t be updated to cover these new versions. Why? Well, Richter wrote an article on his blog answering this question.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The main reason is that the CLR still remains almost untouched, which is the focus of the book. Truly speaking, versions 3.0 and 3.5 run on top of version 2.0.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The explanation he gives in his blog is more complete, my advise is to read it:&lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;a href="http://www.wintellect.com/CS/blogs/jeffreyr/archive/2008/02/18/clr-via-c-will-not-be-updated-for-net-3-5.aspx" target="_blank"&gt;http://www.wintellect.com/CS/blogs/jeffreyr/archive/2008/02/18/clr-via-c-will-not-be-updated-for-net-3-5.aspx&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=4" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-1148816987120951950?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/1148816987120951950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=1148816987120951950&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/1148816987120951950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/1148816987120951950'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/07/clr-via-c.html' title='CLR via C#'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-2149543604429171796</id><published>2008-07-02T21:23:00.014+01:00</published><updated>2009-02-15T01:06:51.250Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='VB.NET'/><title type='text'>Be careful when using IIf</title><content type='html'>&lt;div align="justify"&gt;As I stated before, I’m a C# fan. The language itself is so beautiful that you can write clean and amazingly readable code. For example, recall the ternary expression:&lt;/div&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5218522049364652594" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/SGvqJ6zscjI/AAAAAAAAABw/rhTOqMtFyYU/s400/ternarycsharp.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/02072008/ternarycsharp.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=460,width=960');" /&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;In the above example, we’re testing if the value that the variable “oneValue” contains equals “anotherValue”. If it does, CalculateSomething gets called. Otherwise, CalculateSomethingElse will be called. The result of one of these methods will be stored in the valueToPrint variable. This is the ternary expression.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Now, take a closer look at the CalculateSomethingElse method. As you can see, if we call this method an ArgumentException will be thrown, because we’re trying to convert a non-valid string to an integer. However, in the above example, the value in the “oneValue” variable equals the value in the “anotherValue” variable, so, the CalculateSomethingElse never gets called. If we run this application, everything will go as expected, with no Exceptions thrown:&lt;/div&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5218522251482775090" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_Ae8Ejhv17wA/SGvqVrwaPjI/AAAAAAAAAB4/wZ2TEsxImkg/s400/ternarycsharpresult.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/02072008/ternarycsharpresult.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=260,width=720');" /&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Now, VB.NET has something “similar”: the IIf. Take a look at the VB.NET version of the above example:&lt;/div&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5218522414674322210" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/SGvqfLsToyI/AAAAAAAAACA/lGYyokQGLnQ/s400/ternaryvbdotnet.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/02072008/ternaryvbdotnet.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=420,width=1000');" /&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;The idea is basically the same as for the C# ternary expression. Remember that the CalculateSomethingElse method will throw an ArgumentException when called and the value in the “oneValue” variable equals the “anotherValue”. So, just like what happened with the C# example, you’d expect that everything would compile and run with no Exceptions (since the only method that should be called is the CalculateSomething because the test expression evaluates to true). However, this is not true. If you run the VB.NET example, you will get an ArgumentException:&lt;/div&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5218526868974530466" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/SGvuidQO76I/AAAAAAAAACI/E-COo2XwpDo/s400/ternaryvbdotnetresult.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/02072008/ternaryvbdotnetresult.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=280,width=700');" /&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Why? Well, the IIf is actually a VB.NET function defined in the class Interaction (Microsoft.VisualBasic namespace). The problem with this is that at runtime, both the functions in the IIf get called. This is a major problem when you have large amount of work inside those methods or even something that might thrown an exception (e.g.: divide by zero). The IIf function is as follows:&lt;/div&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5218527066253773490" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_Ae8Ejhv17wA/SGvut8LRSrI/AAAAAAAAACQ/LdV_YcW9qHA/s400/myiif.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/02072008/myiif.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=200,width=900');" /&gt;&lt;div align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="justify"&gt;So, for those VB.NET users, the best is just to use IIf very carefully.&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Tip: Compile both the examples and see the IL that was generated by the compilers.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=3" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-2149543604429171796?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/2149543604429171796/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=2149543604429171796&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/2149543604429171796'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/2149543604429171796'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/07/careful-when-using-iif.html' title='Be careful when using IIf'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Ae8Ejhv17wA/SGvqJ6zscjI/AAAAAAAAABw/rhTOqMtFyYU/s72-c/ternarycsharp.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-3561812434587030397</id><published>2008-06-17T22:12:00.032+01:00</published><updated>2009-02-15T01:06:33.076Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='VB.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>VB.NET Optional parameters</title><content type='html'>&lt;div align="justify"&gt;First of all, let me state: I’m not much of a VB fan. However, the company where I’ve worked for about 8 months had everything implemented with VB.NET (for compatibility reasons – they came from a VB6 era) and I had to get used to it. It wasn’t hard, but I definitely prefer other approaches, like C++ or C#. &lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;But there was one little thing that I enjoyed in VB.NET: optional parameters. Take a look at the following example, specially the doSomething method:&lt;/div&gt;&lt;div align="center"&gt;&lt;br /&gt;&lt;/div&gt;&lt;img id="BLOGGER_PHOTO_ID_5212991381869870866" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_Ae8Ejhv17wA/SFhECs2GvxI/AAAAAAAAAA8/yUkIFgqt8XY/s400/vbdotnetexample.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/vbdotnetexample.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=260,width=780'); "/&gt; &lt;p align="center"&gt;&lt;span style="TEXT-ALIGN: center;font-size:78%;" &gt;(click to enlarge)&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align="justify"&gt;The second parameter is optional. That is, if you don’t specify it in a method call, the compiler (remember, the compiler!) inserts the "False" string for you. If we look at the generated IL, we can see that there’s a false string inserted when we call the method with just one parameter. Despite I wrote different calls to the method, the generated call is exactly the same:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5212991585552236514" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_Ae8Ejhv17wA/SFhEOjnw_-I/AAAAAAAAABE/LRMg67WATU4/s400/vbdotnetil.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/vbdotnetil.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=300,width=760'); " /&gt;&lt;span style="font-size:78%;"&gt;(click to enlarge)&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Also note that I only wrote one method and, accordingly, only one got generated by the compiler. However, the C# (&lt;b&gt;3.0 and below&lt;/b&gt;) compiler doesn’t allow this. To do the same example with C#, we’ll need to write two methods and take advantage of the method overload:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;img id="BLOGGER_PHOTO_ID_5212991727029292914" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_Ae8Ejhv17wA/SFhEWyqhj3I/AAAAAAAAABM/CnGLxsuLcVw/s400/csharpexample.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/csharpexample.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=460,width=800'); " /&gt;&lt;span style="font-size:78%;"&gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;Looking at the generated IL, we’ll see the difference:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5212991865044785986" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: pointer; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_Ae8Ejhv17wA/SFhEe0z-20I/AAAAAAAAABU/ofvX5CDLcNc/s400/csharpil.png" border="0" onclick="window.open('http://anivwatcher.brinkster.net/blogspot/posts/csharpil.png', null,'status=yes,toolbar=no,menubar=no,location=no,height=320,width=760'); " /&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="font-size:78%;"&gt;(click to enlarge)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;br /&gt;Now, the compiler emits the call to different versions of the same method. Of course, two methods were generated. So, why do I like optional parameters?&lt;br /&gt;Well, as you may have noticed, in the C# example I had to wrote two different methods to do the same. And this is the main reason why I think optional parameters are nice. I “googled” a little to find why the C# team decided to keep this feature out, and found a few “pros and cons”:&lt;/div&gt;&lt;br /&gt;Pros &lt;div align="justify"&gt;&lt;ul&gt;&lt;li&gt;Using optional parameters will allow programmers to write less code. Less generated methods.&lt;/li&gt;&lt;li&gt;It’s intuitive.&lt;/li&gt;&lt;li&gt;COM interfaces are filled with default parameters (for example, the Microsoft Office COM automation model - some functions have as many as 30 default parameters). This makes it hard do work with C# (you need to specify all the parameters).&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;p align="justify"&gt;Cons&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div align="justify"&gt;A change in the default parameters will force the user to recompile (imagine if the default parameters change in a server, the client has some troubles).&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;The code generated by the compiler is less obvious (the user didn’t write it).&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align="justify"&gt;Microsoft tries to limit “the magic” because it’s harder to follow up by programmers.&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Optional parameters are not CLS compliant. However, in my opinion, I think it would be good to have them in C#. We had default values in C++, optional parameters exist in VB.NET… We should have them in C#. &lt;/p&gt;&lt;p align="justify"&gt;I don’t think though that they will ever exist in C#. I’m not seeing it in the near future. &lt;br /&gt;&lt;/p&gt;&lt;p align="justify"&gt;Discussion about this issue:&lt;/p&gt;&lt;p align="justify"&gt;&lt;a href="http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85556.aspx"&gt;http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85556.aspx&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;b&gt;Note:&lt;/b&gt; The C# 4.0 will allow optional parameters.&lt;/div&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=2" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-3561812434587030397?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/3561812434587030397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=3561812434587030397&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/3561812434587030397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/3561812434587030397'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/06/vbnet-optional-parameters.html' title='VB.NET Optional parameters'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Ae8Ejhv17wA/SFhECs2GvxI/AAAAAAAAAA8/yUkIFgqt8XY/s72-c/vbdotnetexample.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3636350767852723387.post-5683713653861685343</id><published>2008-06-16T01:25:00.030+01:00</published><updated>2009-02-15T01:03:29.583Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='WF'/><title type='text'>The Listen Activity Issue – State Machines</title><content type='html'>In the past couple of months, I’ve dedicated an amount of my free time to learn Windows Workflow Foundation. The Workflow concept was familiar to me and I was curious about this technology. So far, and there’s only been 6 months since I started this learning, I got to apply this technology a couple of times.&lt;br /&gt;&lt;br /&gt;Why am I writing this post? Well, from all of the scenarios I came across until now, one of the most “tricky” ones is when there’s a timeout situation. Let me explain:&lt;br /&gt;&lt;br /&gt;One of the most common issues every programmer has to deal with is the timeout situation. This situation happens all the time, whether it’s on a synchronous/asynchronous request, a lack of user intervention or even a hardware failure. What to do when there’s no response from a server? Should we wait for ever? Of course not: it’s a timeout!&lt;br /&gt;&lt;br /&gt;Up until now, to deal with this, we’d probably implement a timer and when the time to wait for a response has ended, we should perform a set of actions to compensate this event (e.g.: Cancel the asynchronous request – most common). With Workflow Foundation, a good part of all the work needed to do this is already done! The Listen Activity:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5212269432984944514" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_Ae8Ejhv17wA/SFWzbvqxv4I/AAAAAAAAAAM/hvU9T9F9RVc/s320/listenactivity.png" border="0" /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;/div&gt;The above picture shows the Listen Activity. What is it? Well, it’s a “block” that waits for “n” events and when one of them fires it resumes execution, going down the trail of the event that fired. The other ones are no longer to be “listen”. One of the events can be a delay (a.k.a. timer). Are you already picturing the “timeout situation”? It’s perfect! One event (or more) is what our application wants (e.g.: A document approval from a user) and the other event is the timeout!&lt;br /&gt;&lt;br /&gt;So, why am I complaining? Well, the listen activity is available only for Sequential Workflows. That is, workflows that execute the activities sequentially and the execution of them can’t go back. My loved listen activity can’t be used on State Machine Workflows. According to Kenn Scribner, a software architect and instructor at Wintellect, who wrote Windows Workflow Fountation Step by Step, WF team decided to keep the listen activity out from state machine workflows because it could be a potential cause of deadlocks (witch are not easy to find). I can agree that it could lead to these “tricky” deadlocks, I can even imagine a few ones and tell you how to solve them (don’t ask), but one thing that I can’t understand is why aren’t we able to decide if we want the risk. I mean, we become software engineers for a reason! Solve complicated problems! To come up with solutions for the “hard stuff”!&lt;br /&gt;&lt;br /&gt;Well, of course Microsoft doesn’t do things for no reason, and you can “go around” and implement the listen activity yourself (composite activity) or even use Parallel activity. But this is unnecessary work if we had the listen activity. I sure hope they’ll let us use the listen activity with state machine workflows in the next WF release.&lt;br /&gt;&lt;br /&gt;&lt;iframe src="http://rapidinhas.byethost33.com/blogs/blogspot/feedback/iframe.php?blogpostid=1" width="100%" frameborder="0" height="32px" scrolling="no" &gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3636350767852723387-5683713653861685343?l=cesarafonso.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cesarafonso.blogspot.com/feeds/5683713653861685343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3636350767852723387&amp;postID=5683713653861685343&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/5683713653861685343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3636350767852723387/posts/default/5683713653861685343'/><link rel='alternate' type='text/html' href='http://cesarafonso.blogspot.com/2008/06/listen-activity-issue-state-machines.html' title='The Listen Activity Issue – State Machines'/><author><name>César Afonso</name><uri>http://www.blogger.com/profile/11439986050829015131</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Ae8Ejhv17wA/SFWzbvqxv4I/AAAAAAAAAAM/hvU9T9F9RVc/s72-c/listenactivity.png' height='72' width='72'/><thr:total>1</thr:total></entry></feed>
