<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Righthand's blog</title>
    <description />
    <link>http://blog.rthand.com/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.NET 1.5.0.7</generator>
    <language>en-GB</language>
    <blogChannel:blogRoll>http://blog.rthand.com/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://www.dotnetblogengine.net/syndication.axd</blogChannel:blink>
    <dc:creator>Miha Markic</dc:creator>
    <dc:title>Righthand's blog</dc:title>
    <geo:lat>0.000000</geo:lat>
    <geo:long>0.000000</geo:long>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/RighthandBlogs" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
      <title>Jinxing your application</title>
      <description>&lt;p&gt;If you ever wrote a multithreading application you should understand how hard is to get it right. If you don’t understand it then your application most probably isn’t written correctly.&lt;/p&gt;  &lt;p&gt;You’ve written a multithreaded application and now what. How can you test it whether it is written correctly or not. Unit testing won’t be of great help because there are complex currency issues that might manifest in a bug only under certain circumstances. Imagine this piece of code:&lt;/p&gt;  &lt;pre class="code"&gt;class &lt;span style="color: #2b91af"&gt;Program
&lt;/span&gt;{
    static int x;
    static &lt;span style="color: #2b91af"&gt;Random &lt;/span&gt;rnd = new &lt;span style="color: #2b91af"&gt;Random&lt;/span&gt;();

    static void Main(string[] args)
    {
        &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&lt;&lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;&gt; threads = new &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&lt;&lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;&gt;();
        for (int i = &lt;span style="color: blue"&gt;0&lt;/span&gt;; i &lt; &lt;span style="color: blue"&gt;4&lt;/span&gt;; i++)
        {
            &lt;span style="color: #2b91af"&gt;Thread &lt;/span&gt;t = new &lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;(Runner) { IsBackground = true };
            t.Start();
            threads.Add(t);
        }
        foreach (&lt;span style="color: #2b91af"&gt;Thread &lt;/span&gt;t in threads)
        {
            t.Join();
        }
    }

    static void Runner()
    {
        for (int i = &lt;span style="color: blue"&gt;0&lt;/span&gt;; i &lt; &lt;span style="color: blue"&gt;1000000&lt;/span&gt;; i++)
        {
            &lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;.Sleep(rnd.Next(&lt;span style="color: blue"&gt;10&lt;/span&gt;));
	   int orig = x;
            x += &lt;span style="color: blue"&gt;5&lt;/span&gt;;
            &lt;span style="color: #2b91af"&gt;Debug&lt;/span&gt;.Assert(x == orig+5);        &lt;br /&gt;        }
    }
}&lt;/pre&gt;

&lt;p&gt;I am increasing a shared static variable from multiple threads without any synchronization. Will it work? It might or might not (try it!). It depends on when different threads are accessing the variable &lt;em&gt;x&lt;/em&gt;. One thing is for sure, this code isn’t correct and it most probably won’t work and for sure it won’t work always. That is the biggest problem with multithreading – if something works it doesn’t mean that it it is correctly written and that it will work always. More about this later. If you use unit testing to test &lt;em&gt;runner&lt;/em&gt; method the test will pass because unit testing doesn’t test multithreading, at least not easily.&lt;/p&gt;

&lt;p&gt;So, how does one test such code and scenarios. One way is to use a static analysis tool. The other way is to put a jinx on your application. Once your application is jinxed it will be much more prone to displaying concurrency and other multithreading errors. And that’s exactly what &lt;a href="http://www.petravm.com/" target="_blank"&gt;Jinx&lt;/a&gt; does. Behind the scenes it makes your application fail more often that it would fail in normal circumstances. I mean that it shows faults in the application (if any) that would otherwise remain hidden and would occur only randomly here and there (you know, your user will find it after 2 minutes of running the application) – it doesn’t fail your application for no reason, it just emphasizes your bugs.&lt;/p&gt;

&lt;p&gt;The most interesting aspect of Jinx is its the way it works. Jinx is a sort of hypervisor. You certainly know Hyper-V hypervisor whose task is to run guest operating systems. Jinx’s task is to make a clone of your OS and debugged application within and run multiple versions of it under various conditions. This is done so that any multithreading error is more likely to appear. Just by running more versions of the same application the error is more likely to manifest itself. But Jinx throws all sort of other jinxes to your application as well. That’s the shallow explanation. You’ll find more on &lt;a href="http://www.petravm.com/jinx/" target="_blank"&gt;official overview&lt;/a&gt; page and &lt;a href="http://www.petravm.com/jinx/?page=faq" target="_blank"&gt;FAQ&lt;/a&gt; page.&lt;/p&gt;

&lt;p&gt;So, let’s jinx the code above. Note that if you don’t want to you don’t need any modification of an existing code. Jinx can be set to do its task on any newly run application. However, some fine control is a better way to go. Here are the simple steps for selective jinxing:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Reference &lt;em&gt;jinxinterface&lt;/em&gt; assembly. It contains a single static &lt;em&gt;JinxInteface&lt;/em&gt; class with a bunch of static methods and serves as a communication bridge between application and Jinx. &lt;/li&gt;

  &lt;li&gt;Add &lt;em&gt;jinx.cs&lt;/em&gt; file to your project. Again it contains a single static &lt;em&gt;Jinx&lt;/em&gt; class that is a wrapper around &lt;em&gt;JinxInteface&lt;/em&gt; class mentioned above. Its purpose is mostly to apply &lt;em&gt;Conditional("DEBUG")&lt;/em&gt; over methods so they won’t get executed for non-debug version of the application. &lt;/li&gt;

  &lt;li&gt;Call &lt;strong&gt;Jinx.RegisterApplication(); &lt;/strong&gt;method at start of the application. This way you’ll let Jinx know that your application should use some jinxing. &lt;/li&gt;

  &lt;li&gt;Replace Debug.Assert with Jinx.Assert. The only difference with both asserts is that the latter send statistical information to Jinx. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After the changes the code should look like this:&lt;/p&gt;

&lt;pre class="code"&gt;class &lt;span style="color: #2b91af"&gt;Program
&lt;/span&gt;{
    static int x;
    static &lt;span style="color: #2b91af"&gt;Random &lt;/span&gt;rnd = new &lt;span style="color: #2b91af"&gt;Random&lt;/span&gt;();

    static void Main(string[] args)
    {
        &lt;strong&gt;&lt;span style="color: #2b91af"&gt;Jinx&lt;/span&gt;.RegisterApplication();&lt;/strong&gt;
        &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&lt;&lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;&gt; threads = new &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&lt;&lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;&gt;();
        for (int i = &lt;span style="color: blue"&gt;0&lt;/span&gt;; i &lt; &lt;span style="color: blue"&gt;4&lt;/span&gt;; i++)
        {
            &lt;span style="color: #2b91af"&gt;Thread &lt;/span&gt;t = new &lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;(Runner) { IsBackground = true };
            t.Start();
            threads.Add(t);
        }
        foreach (&lt;span style="color: #2b91af"&gt;Thread &lt;/span&gt;t in threads)
        {
            t.Join();
        }
    }

    static void Runner()
    {
        for (int i = &lt;span style="color: blue"&gt;0&lt;/span&gt;; i &lt; &lt;span style="color: blue"&gt;1000000&lt;/span&gt;; i++)
        {
            &lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;.Sleep(rnd.Next(&lt;span style="color: blue"&gt;10&lt;/span&gt;));
            int orig = x;
            x += &lt;span style="color: blue"&gt;5&lt;/span&gt;;
            &lt;strong&gt;&lt;span style="color: #2b91af"&gt;Jinx&lt;/span&gt;.Assert(x == orig + &lt;span style="color: blue"&gt;5&lt;/span&gt;);&lt;/strong&gt;
        }
    }
}&lt;/pre&gt;

&lt;p&gt;Before any analyzing takes place Jinx should be enabled and set – this is a system wide option. There are two ways to open the Jinx console – either through &lt;em&gt;Tool/Jinx&lt;/em&gt; Visual Studio menu item or directly from &lt;em&gt;All Programs&lt;/em&gt; via start menu. Either way you need Administrator privileges. Enabling is easy, just check Enable Jinx checkbox and that’s it. As per what programs are analyzed I’ll use “Analyze the most recent program I have registered.” option.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=jinx.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="jinx" border="0" alt="jinx" src="http://blog.rthand.com/image.axd?picture=jinx_thumb.png" width="344" height="363" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;You can adjust some strategy settings on Strategy tab, I’ll skip this as it is an advanced option. And you can see the statistics on Status tab. Let’s run the application now. Jinx will kick in and the CPU will get under heavy load and the system might shutter due to Jinx running versions of the application in parallel. But the assert failure pops up almost immediately – the bug was caught for sure. If you run the application without jinxs there error would manifest much more later if at all and note that the test code in question is an extreme example. Here is the status tab page after a couple of errors caught:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=status.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="status" border="0" alt="status" src="http://blog.rthand.com/image.axd?picture=status_thumb.png" width="344" height="363" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The asserts observed counter is increased thanks to Jinx.Assert method call. Jinx analyzer isn’t limited to asserts and it might catch other type of errors as well according to PetraVM guys. Jinx is much more than this simple example.&lt;/p&gt;

&lt;p&gt;So far I’ve run few examples like this and Jinx performed well and I think &lt;strong&gt;Jinx is a good weapon against multithreading bugs&lt;/strong&gt;. However there might be a problem for testing. Since Jinx is a hypervisor on its own it won’t get along with other hypervisors such as Hyper-V. In other words forget about running Jinx on guest OS. A dedicated machine is required. Perhaps this issue will change in the future.&lt;/p&gt;

&lt;p&gt;Also be careful when experimenting with Jinx as it is in &lt;strong&gt;beta&lt;/strong&gt; phase right now (you can apply for testing &lt;a href="http://www.petravm.com/jinx/beta.php" target="_blank"&gt;over here&lt;/a&gt;). Running a beta hypervisor might result in a BSOD and all the consequences from BSOD such as non bootable Windows after. Which happened when I was writing this post. Perhaps this post is jinxed as well :-). Humor aside, I am sure guys behind Jinx will make it rock solid for the RTM. They obviously know very well the hypervisor craft.&lt;/p&gt;

&lt;p&gt;Happy jinxing your applications!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/CUjplg5oUS5hqFSjDEHKp5QwPv4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CUjplg5oUS5hqFSjDEHKp5QwPv4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/CUjplg5oUS5hqFSjDEHKp5QwPv4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CUjplg5oUS5hqFSjDEHKp5QwPv4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RighthandBlogs/~4/nf9f82wqGtw" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RighthandBlogs/~3/nf9f82wqGtw/post.aspx</link>
      <author>Miha Markic</author>
      <comments>http://blog.rthand.com/post/2009/10/26/Jinxing-your-application.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.rthand.com/post.aspx?id=31d381c1-c5d3-4efb-b4e9-6272fb62180a</guid>
      <pubDate>Mon, 26 Oct 2009 13:22:29 +0200</pubDate>
      <category>.net</category>
      <category>Parallel programming</category>
      <category>Windows</category>
      <dc:publisher>Miha Markic</dc:publisher>
      <pingback:server>http://blog.rthand.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.rthand.com/post.aspx?id=31d381c1-c5d3-4efb-b4e9-6272fb62180a</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.rthand.com/trackback.axd?id=31d381c1-c5d3-4efb-b4e9-6272fb62180a</trackback:ping>
      <wfw:comment>http://blog.rthand.com/post/2009/10/26/Jinxing-your-application.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.rthand.com/syndication.axd?post=31d381c1-c5d3-4efb-b4e9-6272fb62180a</wfw:commentRss>
    <feedburner:origLink>http://blog.rthand.com/post.aspx?id=31d381c1-c5d3-4efb-b4e9-6272fb62180a</feedburner:origLink></item>
    <item>
      <title>Things that you didn’t know</title>
      <description>&lt;p&gt;I am working on a some sort of file cache system lately and I’ve encountered a bizarre error. When a certain file representing an image had to be deleted it wouldn’t let it – an &lt;em&gt;IOException&lt;/em&gt; was thrown stating:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The process cannot access the file '[FILEPATH]' because it is being used by another process.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The odd thing is that I’ve used this file only for retrieve images from and I had no idea why would it be locked. Eventually I’ve traced the lock down to this line:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;Image &lt;/span&gt;result = &lt;span style="color: #2b91af"&gt;Image&lt;/span&gt;.FromFile(path);&lt;/pre&gt;
&lt;p&gt;Would you say that the line above would lock a file? I wouldn’t. But it does for some obscure reason. Thus switching to Image.FromStream did the trick:&lt;/p&gt;
&lt;pre class="code"&gt;using (&lt;span style="color: #2b91af"&gt;FileStream &lt;/span&gt;stream = &lt;span style="color: #2b91af"&gt;File&lt;/span&gt;.OpenRead(path))
{
    return &lt;span style="color: #2b91af"&gt;Image&lt;/span&gt;.FromStream(stream);
}&lt;/pre&gt;
&lt;p&gt;It is more lines but it &lt;span style="text-decoration: line-through;"&gt;works as expected&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;IMPORTANT UPDATE: The workaround described above only seems to work - it crashes randomly. By reading documentation (who does that anyway? - thanks Dario for the hint &lt;img title="Smile" src="http://blog.rthand.com/editors/tiny_mce3/plugins/emotions/img/smiley-smile.gif" border="0" alt="Smile" /&gt;) it states that the stream has to open for the lifetime of the Image. Ouch. So here is the second workaround that works for sure - I copy the data to a MemoryStream and create image from there. It is even more lines but this time it has to work (there is a Stream.CopyTo method in forthcomming .net 4.0).&lt;/p&gt;
&lt;p&gt;using (FileStream stream = File.OpenRead(path))&lt;br /&gt;{&lt;br /&gt;    MemoryStream imageDataStream = new MemoryStream(Convert.ToInt32(stream.Length));&lt;br /&gt;    byte[] buffer = new byte[4096];&lt;br /&gt;    int read;&lt;br /&gt;    while ((read = stream.Read(buffer, 0, buffer.Length)) != 0)&lt;br /&gt;    {&lt;br /&gt;        imageDataStream.Write(buffer, 0, read);&lt;br /&gt;    }&lt;br /&gt;    imageDataStream.Position = 0;&lt;br /&gt;    return Image.FromStream(imageDataStream);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/SUnNU4NUyNjyWu_DWs8lpPtIqDY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/SUnNU4NUyNjyWu_DWs8lpPtIqDY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/SUnNU4NUyNjyWu_DWs8lpPtIqDY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/SUnNU4NUyNjyWu_DWs8lpPtIqDY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RighthandBlogs/~4/K0TWCX8ySWc" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RighthandBlogs/~3/K0TWCX8ySWc/post.aspx</link>
      <author>Miha Markic</author>
      <comments>http://blog.rthand.com/post/2009/10/22/Things-that-you-didne28099t-know.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.rthand.com/post.aspx?id=28d0b8a9-6380-4535-a9d5-b1572c7fb25f</guid>
      <pubDate>Thu, 22 Oct 2009 15:42:00 +0200</pubDate>
      <category>.net</category>
      <dc:publisher>Miha Markic</dc:publisher>
      <pingback:server>http://blog.rthand.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.rthand.com/post.aspx?id=28d0b8a9-6380-4535-a9d5-b1572c7fb25f</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.rthand.com/trackback.axd?id=28d0b8a9-6380-4535-a9d5-b1572c7fb25f</trackback:ping>
      <wfw:comment>http://blog.rthand.com/post/2009/10/22/Things-that-you-didne28099t-know.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.rthand.com/syndication.axd?post=28d0b8a9-6380-4535-a9d5-b1572c7fb25f</wfw:commentRss>
    <feedburner:origLink>http://blog.rthand.com/post.aspx?id=28d0b8a9-6380-4535-a9d5-b1572c7fb25f</feedburner:origLink></item>
    <item>
      <title>What’s new in the BCL in .net 4.0 beta 2</title>
      <description>&lt;p&gt;Check out this post about &lt;a href="http://blogs.msdn.com/bclteam/archive/2009/10/21/what-s-new-in-the-bcl-in-net-4-beta-2-justin-van-patten.aspx" target="_blank"&gt;what’s new in the BCL in .net 4.0. beta 2&lt;/a&gt;. As you can see there is a good amount of timesaving functionality.&lt;/p&gt;  &lt;p&gt;My favorites are Stream.CopyTo, String.Concat/Join overloads that take IEnumerable&lt;T&gt; (no more casting IList to Array!) and of course Enum.HasFlag which I &lt;a href="http://blog.rthand.com/post/2007/12/23/Nicer-way-to-check-for-a-flag-presence.aspx" target="_blank"&gt;already implemented it my way&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I wonder though why they created Environment.Is64BitProcess and Is64BitOperatingSystem. At the present time it makes sense but Microsoft is already talking about &lt;a href="http://news.softpedia.com/news/128-bit-Windows-8-and-Windows-9-Explored-by-Microsoft-123691.shtml" target="_blank"&gt;128 bit Windows OS&lt;/a&gt;. We’ll get, I suppose, a couple of years after a 128 bit Windows is released new properties: Environment.Is128BitProcess and Is128BitOperatingSystem and years after that perhaps 256 bit versions of them.&lt;/p&gt;  &lt;p&gt;So, wouldn’t it be easier to have an enum like:&lt;/p&gt;  &lt;pre class="code"&gt;enum &lt;span style="color: #2b91af"&gt;Bitness
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;16Bit&lt;/span&gt;,
    &lt;span style="color: blue"&gt;32Bit&lt;/span&gt;,
    &lt;span style="color: blue"&gt;64Bit
&lt;/span&gt;}&lt;/pre&gt;

&lt;p&gt;And when 128 bit version comes out a new value of 128Bit might be added. So we might have Environment.ProcessBits and Environment.OSBits or something that would return &lt;em&gt;Bitness&lt;/em&gt; enum, would be future proof and easier to use than inspecting all IsXXXBitXXX methods.&lt;/p&gt;

&lt;p&gt;Or perhaps, if adding a new value to an enum poses some kind of problem, just return an int instead of an enum representing the number of bits.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/KE7iCHf32YhbgQRurgxYgPGNwwc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KE7iCHf32YhbgQRurgxYgPGNwwc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/KE7iCHf32YhbgQRurgxYgPGNwwc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KE7iCHf32YhbgQRurgxYgPGNwwc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RighthandBlogs/~4/RobLMYpTUkY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RighthandBlogs/~3/RobLMYpTUkY/post.aspx</link>
      <author>Miha Markic</author>
      <comments>http://blog.rthand.com/post/2009/10/22/Whate28099s-new-in-the-BCL-in-net-40-beta-2.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.rthand.com/post.aspx?id=22785179-62b0-4c1b-9904-20ee29a41682</guid>
      <pubDate>Thu, 22 Oct 2009 09:47:10 +0200</pubDate>
      <category>.net</category>
      <category>4.0</category>
      <dc:publisher>Miha Markic</dc:publisher>
      <pingback:server>http://blog.rthand.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.rthand.com/post.aspx?id=22785179-62b0-4c1b-9904-20ee29a41682</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.rthand.com/trackback.axd?id=22785179-62b0-4c1b-9904-20ee29a41682</trackback:ping>
      <wfw:comment>http://blog.rthand.com/post/2009/10/22/Whate28099s-new-in-the-BCL-in-net-40-beta-2.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.rthand.com/syndication.axd?post=22785179-62b0-4c1b-9904-20ee29a41682</wfw:commentRss>
    <feedburner:origLink>http://blog.rthand.com/post.aspx?id=22785179-62b0-4c1b-9904-20ee29a41682</feedburner:origLink></item>
    <item>
      <title>Visual Studio 2010 beta 2 and .net 4.0 beta 2 available on MSDN</title>
      <description>&lt;p&gt;Both Visual Studio 2010 beta 2 and .net 4.0 beta 2 are available for MSDN subscribers and on Wednesday for everybody. Perhaps an important feature is that a “&lt;a href="http://blogs.msdn.com/jeffbe/archive/2009/10/19/going-live-with-visual-studio-2010-beta-2.aspx" target="_blank"&gt;go live&lt;/a&gt;” license is available.&lt;/p&gt;  &lt;p&gt;Release has been announced for March 22th next year. I guess RTM will be available before the year’s end for MSDN subscribers – judging from the Visual Studio 2008 timeline.&lt;/p&gt;  &lt;p&gt;Here is a bounch of useful beta 2 launch blog posts:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/bharry/archive/2009/10/19/learning-about-vs-2010-beta-2.aspx" target="_blank"&gt;About TFS 2010&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://feedproxy.google.com/~r/ScottHanselman/~3/nlo-NV9tMms/VisualStudio2010Beta2.aspx" target="_blank"&gt;Hanselman’s post&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/jasonz/archive/2009/10/19/announcing-vs2010-net-framework-beta-2.aspx" target="_blank"&gt;Jason Zander’s post&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/pfxteam/archive/2009/10/19/9909371.aspx" target="_blank"&gt;What’s new for the Task Parallel Libary&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/19/vs-2010-and-net-4-0-beta-2.aspx" target="_blank"&gt;ScottGu’s post&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;and of course &lt;a href="http://blogs.msdn.com/somasegar/archive/2009/10/19/announcing-visual-studio-2010-and-net-fx-4-beta-2.aspx" target="_blank"&gt;Somma’s post&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Just don’t forget that this is beta 2 release and you should be cautious – installing it in a virtual machine rather then production one is always a good practice when dealing with early builds.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XAv_fkehST5-k817PM5vYCVJuVE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XAv_fkehST5-k817PM5vYCVJuVE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XAv_fkehST5-k817PM5vYCVJuVE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XAv_fkehST5-k817PM5vYCVJuVE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RighthandBlogs/~4/MshdRggjdtM" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RighthandBlogs/~3/MshdRggjdtM/post.aspx</link>
      <author>Miha Markic</author>
      <comments>http://blog.rthand.com/post/2009/10/20/Visual-Studio-2010-beta-2-and-net-40-beta-2-available-on-MSDN.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.rthand.com/post.aspx?id=e691775e-0d74-49d7-ad18-bd7517c4e520</guid>
      <pubDate>Tue, 20 Oct 2009 10:14:54 +0200</pubDate>
      <category>2010</category>
      <category>4.0</category>
      <category>.net</category>
      <category>Visual Studio</category>
      <dc:publisher>Miha Markic</dc:publisher>
      <pingback:server>http://blog.rthand.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.rthand.com/post.aspx?id=e691775e-0d74-49d7-ad18-bd7517c4e520</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.rthand.com/trackback.axd?id=e691775e-0d74-49d7-ad18-bd7517c4e520</trackback:ping>
      <wfw:comment>http://blog.rthand.com/post/2009/10/20/Visual-Studio-2010-beta-2-and-net-40-beta-2-available-on-MSDN.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.rthand.com/syndication.axd?post=e691775e-0d74-49d7-ad18-bd7517c4e520</wfw:commentRss>
    <feedburner:origLink>http://blog.rthand.com/post.aspx?id=e691775e-0d74-49d7-ad18-bd7517c4e520</feedburner:origLink></item>
    <item>
      <title>Dealing with iterations over null lists in LINQ to Objects</title>
      <description>&lt;h1&gt;Problem&lt;/h1&gt;
&lt;p&gt;If you used LINQ to Objects you have certainly come across iterations over null values resulting in an ArgumentNullException being thrown at you.&lt;/p&gt;
&lt;p&gt;See this example:&lt;/p&gt;
&lt;pre class="code"&gt;int[] b = &lt;strong&gt;null&lt;/strong&gt;;
&lt;strong&gt;var&lt;/strong&gt; query = &lt;strong&gt;from&lt;/strong&gt; i &lt;strong&gt;in&lt;/strong&gt; b &lt;strong&gt;select&lt;/strong&gt; i;&lt;/pre&gt;
&lt;p&gt;In the case above the error is obvious but if the list comes as an argument of a method or some more complicated way it is hard to spot it. Sure, the obvious solution is an easy one. A simple if statement before will do it:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;strong&gt;if&lt;/strong&gt; (b != &lt;strong&gt;null&lt;/strong&gt;)
    &lt;strong&gt;var&lt;/strong&gt; query = &lt;strong&gt;from&lt;/strong&gt; i &lt;strong&gt;in&lt;/strong&gt; b &lt;strong&gt;select&lt;/strong&gt; i;&lt;/pre&gt;
&lt;p&gt;What about nested loops? Like this&lt;/p&gt;
&lt;pre class="code"&gt;&lt;strong&gt;class&lt;/strong&gt; Tubo&lt;br /&gt;{&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;strong&gt;string&lt;/strong&gt;&gt; Strings;&lt;br /&gt;}&lt;br /&gt;...&lt;br /&gt;IList&amp;lt;Tubo&gt; tubos = ...;&lt;br /&gt;&lt;strong&gt;var&lt;/strong&gt; query = &lt;strong&gt;from&lt;/strong&gt; t &lt;strong&gt;in&lt;/strong&gt; tubos&lt;br /&gt;            &lt;strong&gt;from&lt;/strong&gt; s &lt;strong&gt;in&lt;/strong&gt; t.Strings&lt;br /&gt;            &lt;strong&gt;select&lt;/strong&gt; s;&lt;/pre&gt;
&lt;p&gt;Sure, we could add guardian clauses like the if before:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;strong&gt;if&lt;/strong&gt; (tubos != &lt;strong&gt;null&lt;/strong&gt;)
     &lt;strong&gt;var&lt;/strong&gt; query = &lt;strong&gt;from&lt;/strong&gt; t &lt;strong&gt;in&lt;/strong&gt; tubos
        &lt;strong&gt;where&lt;/strong&gt; t.Strings != &lt;strong&gt;null&lt;/strong&gt;
        &lt;strong&gt;from&lt;/strong&gt; s &lt;strong&gt;in&lt;/strong&gt; t.Strings
        &lt;strong&gt;select&lt;/strong&gt; s;&lt;/pre&gt;
&lt;p&gt;The problem with this approach is that it gets cluttered and it complicates the flow, specially the first if.&lt;/p&gt;
&lt;h1&gt;Solution&lt;/h1&gt;
&lt;p&gt;So, here is my proposal and I am sure it has been proposed before (I just couldn’t find it on Google, err, I mean internet).&lt;/p&gt;
&lt;pre class="code"&gt;&lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;strong&gt;class&lt;/strong&gt; &lt;span style="color: #2b91af"&gt;Extension&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; &lt;span style="color: #2b91af"&gt;IList&lt;/span&gt;&amp;lt;T&gt; Safe&amp;lt;T&gt;(&lt;strong&gt;this&lt;/strong&gt; &lt;span style="color: #2b91af"&gt;IList&lt;/span&gt;&amp;lt;T&gt; source)&lt;br /&gt;    {&lt;br /&gt;        &lt;strong&gt;if&lt;/strong&gt; (source == &lt;strong&gt;null&lt;/strong&gt;)&lt;br /&gt;            &lt;strong&gt;return&lt;/strong&gt; &lt;strong&gt;new&lt;/strong&gt; T[&lt;span style="color: blue"&gt;0&lt;/span&gt;];&lt;br /&gt;        &lt;strong&gt;else&lt;/strong&gt;
            &lt;strong&gt;return&lt;/strong&gt; source;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p&gt;The extension method makes sure that query always gets a non-null list by making an empty one if it is null. The trick with extension method is that they can be invoked on null values which are passed as &lt;em&gt;this &lt;/em&gt;argument.&lt;/p&gt;
&lt;p&gt;And the last nested LINQ to Objects loop would look like:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;strong&gt;var&lt;/strong&gt; query = &lt;strong&gt;from&lt;/strong&gt; t &lt;strong&gt;in&lt;/strong&gt; tubos.Safe()
             &lt;strong&gt;from&lt;/strong&gt; s &lt;strong&gt;in&lt;/strong&gt; t.Strings.Safe()
             &lt;strong&gt;select&lt;/strong&gt; s;&lt;/pre&gt;
&lt;p&gt;I am not sure that the extension method name Safe is adequate or not but it sure does help in code readability.&lt;/p&gt;
&lt;p&gt;What do you say?&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Jj9T0y7nLLdSmnPhcVq16po7O10/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Jj9T0y7nLLdSmnPhcVq16po7O10/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Jj9T0y7nLLdSmnPhcVq16po7O10/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Jj9T0y7nLLdSmnPhcVq16po7O10/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RighthandBlogs/~4/qhJv_S1IKZY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RighthandBlogs/~3/qhJv_S1IKZY/post.aspx</link>
      <author>Miha Markic</author>
      <comments>http://blog.rthand.com/post/2009/10/15/Dealing-with-iterations-over-null-lists-in-LINQ-to-Objects.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.rthand.com/post.aspx?id=1c4d6122-7d11-4b14-935a-824c91a53ec5</guid>
      <pubDate>Thu, 15 Oct 2009 10:41:00 +0200</pubDate>
      <category>.net</category>
      <category>3.5</category>
      <category>4.0</category>
      <category>LINQ</category>
      <dc:publisher>Miha Markic</dc:publisher>
      <pingback:server>http://blog.rthand.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.rthand.com/post.aspx?id=1c4d6122-7d11-4b14-935a-824c91a53ec5</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://blog.rthand.com/trackback.axd?id=1c4d6122-7d11-4b14-935a-824c91a53ec5</trackback:ping>
      <wfw:comment>http://blog.rthand.com/post/2009/10/15/Dealing-with-iterations-over-null-lists-in-LINQ-to-Objects.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.rthand.com/syndication.axd?post=1c4d6122-7d11-4b14-935a-824c91a53ec5</wfw:commentRss>
    <feedburner:origLink>http://blog.rthand.com/post.aspx?id=1c4d6122-7d11-4b14-935a-824c91a53ec5</feedburner:origLink></item>
    <item>
      <title>.net reflector pro is awesome</title>
      <description>&lt;h2&gt;.net reflector&lt;/h2&gt;  &lt;p&gt;I am sure we all know and love &lt;a href="http://www.red-gate.com/products/reflector/" target="_blank"&gt;.net reflector&lt;/a&gt; originally developed by Lutz Roeder and took over by fine folks at &lt;a href="http://www.red-gate.com/" target="_blank"&gt;Red Gate&lt;/a&gt;. If you don’t know what .net reflector is or what it does you must take a look. It is an indispensible tool for understanding how a certain assembly (i.e. from .net framework or 3rd party) works – .net reflector does that by disassembling assemblies into C#/VB/IL/whatever (whatever code is achieved through a right plugin) code you want. And based on all this information it can provide you a ton of useful data, i.e. who uses which type, what types are derived from a type, etc.&lt;/p&gt;  &lt;h2&gt;.net reflector pro&lt;/h2&gt;  &lt;p&gt;And now there is a PRO version with a kick ass feature – it lets you step through source code even for referenced assemblies without sources while debugging an application under Visual Studio 2005/2008/2010. The functionality is similar to using &lt;a href="http://blog.rthand.com/post/2008/01/17/A-part-of-NET-Framework-Source-Code-is-available-for-debugging-purposes.aspx" target="_blank"&gt;symbols&lt;/a&gt; for same purposes. But it is a lot better because you aren’t constrained to assembly vendor as vendor has to provide symbol files for you to debug them. .net reflector pro does the trick for any assembly, regardless of the origin. True, it is useless with obfuscated assemblies and it doesn’t provide comments but hey – AFAIK right now there is only Microsoft providing some, not all, symbol files. You are out of luck for other Microsoft and 3rd party assemblies in this case.&lt;/p&gt;  &lt;p&gt;Let me tell you an example. I’ve been bugging &lt;a href="http://www.devexpress.com/" target="_blank"&gt;Developer Express&lt;/a&gt; guys for a while to provide symbol files and they probably will, but who knows when because this task is a low priority one for them. Now, with .net reflector pro I don’t need those files anymore nor I need any other 3rd party vendor symbol files.&lt;/p&gt;  &lt;h2&gt;The question is why would I want this feature at all?&lt;/h2&gt;  &lt;p&gt;This question should be asked only by a beginner. Everybody that did some serious development knows how important is to understand how a certain feature in a certain assembly is working, specially when you are presented an exception dialog and you have to understand what happened, what went wrong. Normally if you try digging the call stack to show code some code below your methods &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=call%20stack.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="call stack" border="0" alt="call stack" src="http://blog.rthand.com/image.axd?picture=call%20stack_thumb.png" width="644" height="170" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;(double click on a method where you don’t have source code – almost all call stack is gray meaning there is no source code available) you are presented with this informative dialog:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=no%20source%20code.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="no source code" border="0" alt="no source code" src="http://blog.rthand.com/image.axd?picture=no%20source%20code_thumb.png" width="507" height="203" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Go ahead, if you are an assembler guy, click &lt;em&gt;Show Disassembly&lt;/em&gt;. For mere mortals disassembler code is useless.&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;How to use .net reflector pro&lt;/h2&gt;  &lt;p&gt;Download early access program version from &lt;a href="http://www.red-gate.com/MessageBoard/viewtopic.php?t=9722" target="_blank"&gt;.net reflector pro forum&lt;/a&gt;, unzip it somewhere and run reflector.exe. By running the executable for at least once you will register the Visual Studio addin that integrates .net reflector pro into Visual Studio. Without the addin registered nothing will happen in Visual Studio.&lt;/p&gt;  &lt;p&gt;Run Visual Studio. Take note that there is a new root menu entry - &lt;em&gt;.NET Reflector&lt;/em&gt;. Next create a test application – mine will be a WinForms one hosting a single SimpleButton from &lt;a href="http://www.devexpress.com/" target="_blank"&gt;DevExpress&lt;/a&gt;. I’ll implement its Click event and put a breakpoint there. No additional code.&lt;/p&gt;  &lt;p&gt;Run the application. If you have turned on Just My Code debugging setting then you’ll be prompted by a .net reflector dialog like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=turnoffjustmycode.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="turnoffjustmycode" border="0" alt="turnoffjustmycode" src="http://blog.rthand.com/image.axd?picture=turnoffjustmycode_thumb.png" width="587" height="427" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You have to turn off Just My Code feature. This is the same restriction as with symbol files. Then you’ll be presented another dialog where you can select which assemblies are you interested in:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=assemblyselection.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="assemblyselection" border="0" alt="assemblyselection" src="http://blog.rthand.com/image.axd?picture=assemblyselection_thumb.png" width="587" height="427" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select all assemblies. Once you hit OK button .net reflector will start decompiling assemblies by using all available cores on the computer (note that there are many entries in “In progress” state running in parallel). &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=decompiling.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="decompiling" border="0" alt="decompiling" src="http://blog.rthand.com/image.axd?picture=decompiling_thumb.png" width="587" height="427" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This is the first application I use that actually use all of my Core i7 4+4 cores. Good job and very smart because decompiling so many assemblies even in parallel takes a around 10 minutes on my Core i7 920 computer. But don’t fear – the results are cached and next run there is almost no performance hit at the start. That’s it for configuration and single window application will finally run.&lt;/p&gt;  &lt;p&gt;The application will present a default window with a single button. Click on the button and execution will hit a breakpoint you’ve put in button’s Click handler. Look at the call stack again - it isn’t gray anymore:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=newcallstack.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="newcallstack" border="0" alt="newcallstack" src="http://blog.rthand.com/image.axd?picture=newcallstack_thumb.png" width="644" height="170" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;And double clicking on the &lt;em&gt;BaseButton.OnClick&lt;/em&gt; call stack entry opens decompiled source code from DevExpress assembly with everything except the Edit&amp;Continue feature.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=kickass.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="kickass" border="0" alt="kickass" src="http://blog.rthand.com/image.axd?picture=kickass_thumb.png" width="602" height="344" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Let me repeat. The code above comes from an assembly decompilation and it is almost as useful as normal source code in debugger. You can inspect the variables and step forth and back but, of course, you can’t change it. Or better, you can change it but it won’t be recompiled.&lt;/p&gt;  &lt;p&gt;No more black boxes! Now, if this isn’t an awesome feature, a must must have one, I don’t really know what such a feature is.&lt;/p&gt;  &lt;p&gt;There is a slight drawback though: pro version won’t be free, which isn’t a big surprise and not a big issue. The regular version will continue to be free but it won’t have the *feature*. Also currently, being in beta, there are some bugs here and there which should disappear by RTM I guess.&lt;/p&gt;  &lt;p&gt;More (official) information on this &lt;a href="http://www.simple-talk.com/community/blogs/alex/archive/2009/09/22/74919.aspx" target="_blank"&gt;Alex Davies' blog post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MvZepkeHLZ-6d4goOfjfIT8Iw9E/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MvZepkeHLZ-6d4goOfjfIT8Iw9E/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MvZepkeHLZ-6d4goOfjfIT8Iw9E/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MvZepkeHLZ-6d4goOfjfIT8Iw9E/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RighthandBlogs/~4/nVm5zmN37vw" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RighthandBlogs/~3/nVm5zmN37vw/post.aspx</link>
      <author>Miha Markic</author>
      <comments>http://blog.rthand.com/post/2009/10/07/net-reflector-pro-is-awesome.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.rthand.com/post.aspx?id=10f26a86-6ad9-4f5b-b8a5-473d6b2bf3ec</guid>
      <pubDate>Wed, 07 Oct 2009 09:20:25 +0200</pubDate>
      <category>Visual Studio</category>
      <category>Add In</category>
      <category>Parallel programming</category>
      <category>Red Gate</category>
      <dc:publisher>Miha Markic</dc:publisher>
      <pingback:server>http://blog.rthand.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.rthand.com/post.aspx?id=10f26a86-6ad9-4f5b-b8a5-473d6b2bf3ec</pingback:target>
      <slash:comments>5</slash:comments>
      <trackback:ping>http://blog.rthand.com/trackback.axd?id=10f26a86-6ad9-4f5b-b8a5-473d6b2bf3ec</trackback:ping>
      <wfw:comment>http://blog.rthand.com/post/2009/10/07/net-reflector-pro-is-awesome.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.rthand.com/syndication.axd?post=10f26a86-6ad9-4f5b-b8a5-473d6b2bf3ec</wfw:commentRss>
    <feedburner:origLink>http://blog.rthand.com/post.aspx?id=10f26a86-6ad9-4f5b-b8a5-473d6b2bf3ec</feedburner:origLink></item>
    <item>
      <title>The slides and code from my “Making asp.net mvc applications strong typed” presentation</title>
      <description>&lt;p&gt;Yesterday I held a presentation (as the part of &lt;a href="http://www.bleedingedge.si/"&gt;Bleeding Edge 2009&lt;/a&gt; conference) on how to make ASP.NET MVC applications strong typed by using &lt;a href="http://www.codesmithtools.com/"&gt;CodeSmith&lt;/a&gt; and &lt;a href="http://www.devexpress.com/coderush/"&gt;CodeRush&lt;/a&gt; (actually by using its free DXCore part). Attendees were great and the presentation went well. Attached are the slides in Slovene and source code in C#.&lt;/p&gt;  &lt;p&gt;If you are interested in the topic you might read my previous blog posts as well:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blog.rthand.com/post/2009/04/18/Strong-typing-views-in-ASPNET-MVC.aspx" target="_blank"&gt;Strong typing views in ASP.NET MVC&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blog.rthand.com/post/2009/04/21/Strong-typing-routes-in-ASPNET-MVC.aspx" target="_blank"&gt;Strong typing routes in ASP.NET MVC&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blog.rthand.com/post/2009/04/22/Enhancing-strong-typed-views-in-ASPNET-MVC.aspx" target="_blank"&gt;Enhancing strong typed views in ASP.NET MVC&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blog.rthand.com/post/2009/04/30/RenderPartialToString-missing-in-ASPNET-MVC.aspx" target="_blank"&gt;RenderPartialToString missing in ASP.NET MVC&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Thanks everybody for attending the presentation.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:3ad0621e-573f-47c6-8a76-89909a65bbad" class="wlWriterEditableSmartContent"&gt;&lt;p&gt;&lt;div&gt;&lt;a href="http://blog.rthand.com/file.axd?file=BleedForEdge_StrongTypedAspNetMvc.zip" target="_self"&gt;BleedForEdge_StrongTypedAspNetMvc.zip&lt;/a&gt;&lt;/div&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/0iV97OoA44ib6KAT4eYJtBBnPZE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/0iV97OoA44ib6KAT4eYJtBBnPZE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/0iV97OoA44ib6KAT4eYJtBBnPZE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/0iV97OoA44ib6KAT4eYJtBBnPZE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RighthandBlogs/~4/Gt4FTCc9IIY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RighthandBlogs/~3/Gt4FTCc9IIY/post.aspx</link>
      <author>Miha Markic</author>
      <comments>http://blog.rthand.com/post/2009/10/02/The-slides-and-code-from-my-e2809cMaking-aspnet-mvc-applications-strong-typede2809d-presentation.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.rthand.com/post.aspx?id=536d0b1d-d3d6-45eb-be64-5a42a448a650</guid>
      <pubDate>Fri, 02 Oct 2009 10:57:40 +0200</pubDate>
      <category>.net</category>
      <category>2008</category>
      <category>asp.net mvc</category>
      <category>CodeRush</category>
      <category>CodeSmith</category>
      <category>DXCore</category>
      <category>DXCore plugin</category>
      <category>Presentation</category>
      <category>Visual Studio</category>
      <dc:publisher>Miha Markic</dc:publisher>
      <pingback:server>http://blog.rthand.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.rthand.com/post.aspx?id=536d0b1d-d3d6-45eb-be64-5a42a448a650</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.rthand.com/trackback.axd?id=536d0b1d-d3d6-45eb-be64-5a42a448a650</trackback:ping>
      <wfw:comment>http://blog.rthand.com/post/2009/10/02/The-slides-and-code-from-my-e2809cMaking-aspnet-mvc-applications-strong-typede2809d-presentation.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.rthand.com/syndication.axd?post=536d0b1d-d3d6-45eb-be64-5a42a448a650</wfw:commentRss>
    <feedburner:origLink>http://blog.rthand.com/post.aspx?id=536d0b1d-d3d6-45eb-be64-5a42a448a650</feedburner:origLink></item>
    <item>
      <title>Putting sleepless Windows 7 to sleep</title>
      <description>&lt;p&gt;A while ago I had the &lt;a href="http://blog.rthand.com/post/2006/12/11/Putting-sleepless-Vista-to-sleep.aspx"&gt;problem with Vista&lt;/a&gt;. The thing was that it woke up randomly from the sleep state. The same problem reappeared when I’ve upgraded to Windows 7 x64. But the solution I’ve found previously didn’t work anymore. Even turning off all wake up features for each device didn’t make any difference. Computer would just wake up in the middle of night and stay awake. Besides unpleasant noise there is also unnecessary power consumption.&lt;/p&gt;  &lt;p&gt;However it looks like I’ve found the solution once again and this time it is a much more clean and an obvious one. Go to &lt;em&gt;Control Panel&lt;/em&gt;, &lt;em&gt;Power Options&lt;/em&gt; and click on &lt;em&gt;Change plan settings&lt;/em&gt; of the currently selected plan.&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=poweroptions.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="poweroptions" border="0" alt="poweroptions" src="http://blog.rthand.com/image.axd?picture=poweroptions_thumb.png" width="644" height="303" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="left"&gt;Next click on &lt;em&gt;Change advanced power settings&lt;/em&gt;&lt;/p&gt;  &lt;p align="left"&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=balanced.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="balanced" border="0" alt="balanced" src="http://blog.rthand.com/image.axd?picture=balanced_thumb.png" width="452" height="367" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="left"&gt;And finally disable &lt;em&gt;Allow wake timers&lt;/em&gt; in &lt;em&gt;Sleep&lt;/em&gt; node.&lt;/p&gt;  &lt;p align="left"&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=final.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="final" border="0" alt="final" src="http://blog.rthand.com/image.axd?picture=final_thumb.png" width="452" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="left"&gt;That’s it. Your Windows 7 computer will sleep like a baby again.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/GDwvc9a6E-E152JiSCxml41XULk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GDwvc9a6E-E152JiSCxml41XULk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/GDwvc9a6E-E152JiSCxml41XULk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GDwvc9a6E-E152JiSCxml41XULk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RighthandBlogs/~4/4iTUc0B_oV4" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RighthandBlogs/~3/4iTUc0B_oV4/post.aspx</link>
      <author>Miha Markic</author>
      <comments>http://blog.rthand.com/post/2009/09/21/Putting-sleepless-Windows-7-to-sleep.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.rthand.com/post.aspx?id=e95e4378-fc78-4687-987a-5c98ddcdb9d9</guid>
      <pubDate>Mon, 21 Sep 2009 09:11:39 +0200</pubDate>
      <category>Windows</category>
      <category>7</category>
      <dc:publisher>Miha Markic</dc:publisher>
      <pingback:server>http://blog.rthand.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.rthand.com/post.aspx?id=e95e4378-fc78-4687-987a-5c98ddcdb9d9</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.rthand.com/trackback.axd?id=e95e4378-fc78-4687-987a-5c98ddcdb9d9</trackback:ping>
      <wfw:comment>http://blog.rthand.com/post/2009/09/21/Putting-sleepless-Windows-7-to-sleep.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.rthand.com/syndication.axd?post=e95e4378-fc78-4687-987a-5c98ddcdb9d9</wfw:commentRss>
    <feedburner:origLink>http://blog.rthand.com/post.aspx?id=e95e4378-fc78-4687-987a-5c98ddcdb9d9</feedburner:origLink></item>
    <item>
      <title>Reversing for loops with CodeRush</title>
      <description>&lt;p&gt;Imagine you have to delete a bunch of items from a list, something like this:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
&lt;pre id="codeSnippet" style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;List&lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&gt; items = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&gt;();&lt;br /&gt;...&lt;br /&gt;&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = 2; i &lt; items.Count; i++)&lt;br /&gt;{&lt;br /&gt;    items.RemoveAt(i);&lt;br /&gt;}&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;Will it work? Of course not because you are removing items while your are looping the entire list. That means sooner or later you’ll bump against out of index exception or items silently won’t be removed. And this is a common mistake we all do I suppose.&lt;/p&gt;
&lt;p&gt;The solution is a pretty easy one – reverse the for loop, like this:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
&lt;pre id="codeSnippet" style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = items.Count - 1; i &gt;= 2; i--)&lt;br /&gt;{&lt;br /&gt;    items.RemoveAt(i);&lt;br /&gt;}&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;However I find writing reverse loops harder than the former one. Not sure why but I guess that’s how I am used to do the maths – addition is always easier compared to subtraction.&lt;/p&gt;
&lt;p&gt;Luckily there is &lt;a href="http://www.devexpress.com/coderush" target="_blank"&gt;CodeRush&lt;/a&gt; to the rescue. Just execute the Reverse For Loop code reformatting (not refactoring because you do change the meaning of the code with this one) and you are done.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=cr.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="cr" src="http://blog.rthand.com/image.axd?picture=cr_thumb.png" border="0" alt="cr" width="371" height="287" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It works the other direction as well. Until today I didn’t even know that this trick exists. I just assumed it does and it sure did exist. This and a “million” of other features makes &lt;a href="http://www.devexpress.com/coderush" target="_blank"&gt;CodeRush&lt;/a&gt; really a must have coding tool.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ntTLquos1tDO5CBUog5hF3wijDE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ntTLquos1tDO5CBUog5hF3wijDE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ntTLquos1tDO5CBUog5hF3wijDE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ntTLquos1tDO5CBUog5hF3wijDE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RighthandBlogs/~4/Z99XJ2o2vQo" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RighthandBlogs/~3/Z99XJ2o2vQo/post.aspx</link>
      <author>Miha Markic</author>
      <comments>http://blog.rthand.com/post/2009/09/17/Reversing-for-loops-with-CodeRush.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.rthand.com/post.aspx?id=c429268e-1140-46b3-aac4-4cf82c347c3c</guid>
      <pubDate>Thu, 17 Sep 2009 13:19:00 +0200</pubDate>
      <category>.net</category>
      <category>CodeRush</category>
      <category>DevExpress</category>
      <category>Visual Studio</category>
      <dc:publisher>Miha Markic</dc:publisher>
      <pingback:server>http://blog.rthand.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.rthand.com/post.aspx?id=c429268e-1140-46b3-aac4-4cf82c347c3c</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://blog.rthand.com/trackback.axd?id=c429268e-1140-46b3-aac4-4cf82c347c3c</trackback:ping>
      <wfw:comment>http://blog.rthand.com/post/2009/09/17/Reversing-for-loops-with-CodeRush.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.rthand.com/syndication.axd?post=c429268e-1140-46b3-aac4-4cf82c347c3c</wfw:commentRss>
    <feedburner:origLink>http://blog.rthand.com/post.aspx?id=c429268e-1140-46b3-aac4-4cf82c347c3c</feedburner:origLink></item>
    <item>
      <title>Investigating Windows BSOD cause for dummies</title>
      <description>&lt;p&gt;Does your Windows displays nice, we all love, BSOD once in a while or perhaps, god forbid, often? There are two most plausible suspects for this behavior. And no, it is rarely Windows fault. Instead it is either hardware or driver and I won’t even dig into the quality of drivers produced by various hardware companies.&lt;/p&gt;
&lt;p&gt;But the big question here is, which one? Which driver? Which hardware? It is even harder to pinpoint the cause in case when BSOD occurs at random times. Luckily there is a tool that might shade some light on the mystery and point cyber finger at the offending driver: &lt;a href="http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx" target="_blank"&gt;Microsoft Debugging Tools for Windows&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;Recipe for using Debugging Tools&lt;/h1&gt;
&lt;p&gt;The recipe is shown on Windows 7 but it is very much the same for other Windows flavors.&lt;/p&gt;
&lt;p&gt;1. Make sure your BSODs are producing memory dumps.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt; &lt;ol&gt;
&lt;li&gt;Right click on Computer, pick &lt;em&gt;Properties&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;On the left side click &lt;em&gt;Advanced system settings&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Select &lt;em&gt;Advanced&lt;/em&gt; tab, you’ll see this window        &lt;br /&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=dm1.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="dm1" src="http://blog.rthand.com/image.axd?picture=dm1_thumb.png" border="0" alt="dm1" width="430" height="478" /&gt;&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Click &lt;em&gt;Settings…&lt;/em&gt; button in &lt;em&gt;Startup and&lt;/em&gt; &lt;em&gt;Recovery Group&lt;/em&gt; to see this window&lt;br /&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=dm2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="dm2" src="http://blog.rthand.com/image.axd?picture=dm2_thumb.png" border="0" alt="dm2" width="404" height="474" /&gt;&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Make sure that &lt;em&gt;Kernel memory dump&lt;/em&gt; or at least &lt;em&gt;Small memory dump (256KB)&lt;/em&gt; is selected (it should be on by default). That way Windows will store the forensic evidence of the crash.&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;2. Install appropriate (x86, x64 or Itanium) version of &lt;a href="http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx" target="_blank"&gt;Microsoft Debugging Tools for Windows&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;3. Run WinDbg debugger (installed as a part of package in previous step) as administrator (Right click/&lt;em&gt;Run as administrator&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;4. Setup symbols server path so the tool can output human readable information instead of hex codes.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Pick &lt;em&gt;File/Symbol File Path…&lt;/em&gt; menu item and enter the following line into the text box:      &lt;br /&gt;&lt;strong&gt;SRV*c:\symbols*http://msdl.microsoft.com/download/symbols&lt;/strong&gt; &lt;br /&gt;This line instructs WinDbg where to download symbols from (in this case it will be public Microsoft server). Also note that &lt;em&gt;c:\symbols&lt;/em&gt; is folder on my disk where WinDbg will cache the symbols. You are free to use whatever other folder.      &lt;br /&gt;Note: there are other ways for obtaining the symbols, this is just the easiest one.      &lt;br /&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=d1.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="d1" src="http://blog.rthand.com/image.axd?picture=d1_thumb.png" border="0" alt="d1" width="568" height="207" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;5. Now you are ready for some real action. If your BSOD produced memory dump you’ll find it in &lt;em&gt;C:\Windows\Minidump&lt;/em&gt; folder (default location). Pick &lt;em&gt;File/Open Crash Dump…&lt;/em&gt; menu item and search for a memory dump file. Once you open a file WinDbg will present you a window like this (note, &lt;strong&gt;the first time it make take a while because WinDbg will download symbols from the internet&lt;/strong&gt;):    &lt;br /&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=d2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="d2" src="http://blog.rthand.com/image.axd?picture=d2_thumb.png" border="0" alt="d2" width="644" height="395" /&gt;&lt;/a&gt; &lt;br /&gt;Here you’ll find the first clue of the offender, see line which starts with &lt;em&gt;Probably caused by.&lt;/em&gt; The text probably won’t tell you much more, so here is the magic wand command.&lt;/p&gt;
&lt;p&gt;6. Either click on &lt;strong&gt;!analyze –v&lt;/strong&gt; or type it into the command line at the bottom and press enter. A better description of the error will appear such as this one:    &lt;br /&gt;&lt;a href="http://blog.rthand.com/image.axd?picture=d3.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="d3" src="http://blog.rthand.com/image.axd?picture=d3_thumb.png" border="0" alt="d3" width="644" height="327" /&gt;&lt;/a&gt; &lt;br /&gt;Here is a much more (human readable) information you can use to understand the cause of the BSOD. There is an offending process or driver and even a call stack. Specially the former should give you a hint who is causing the problem. Or perhaps you’ll find it in the call stack among system functions. Unfortunately the given sample is not the best one because at the moment I don’t have any better since I didn’t run into BSOD for a long time except the given sample on my wife’s computer. Csrss.exe doesn’t tell me much because the real source is hidden probably by a hardware issue. But if it was soundblaster.dll or &lt;a href="http://www.nvidia.com/" target="_blank"&gt;nvidia&lt;/a&gt;.dll or &lt;a href="http://www.ati.com/" target="_blank"&gt;ati&lt;/a&gt;.dll it would be very obvious who is the cause, wouldn’t it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Here is my advice: search for a known dll/exe on this screen and if you find one you probably found the cause.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Well, I am not a die hard debugging guy but I often did find the cause of my BSODs this way. I am sure skilled people can use WinDbg much better than me. However often you’ll be able to understand the BSOD cause by yourself simply running WinDbg and !analyze –v command. And you’ll agree that there is no better feeling than solving such an annoying problem by yourself.&lt;/p&gt;
&lt;p&gt;Happy hunting!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ak_x7yAt_viwvCDQw6vJwJFSNYk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ak_x7yAt_viwvCDQw6vJwJFSNYk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ak_x7yAt_viwvCDQw6vJwJFSNYk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ak_x7yAt_viwvCDQw6vJwJFSNYk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RighthandBlogs/~4/CBJMCOqtIoc" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/RighthandBlogs/~3/CBJMCOqtIoc/post.aspx</link>
      <author>Miha Markic</author>
      <comments>http://blog.rthand.com/post/2009/09/13/Investigating-Windows-BSOD-cause-for-dummies.aspx#comment</comments>
      <guid isPermaLink="false">http://blog.rthand.com/post.aspx?id=242012c5-80c2-44d4-9924-1d27842e99e7</guid>
      <pubDate>Sun, 13 Sep 2009 21:57:00 +0200</pubDate>
      <category>Windows</category>
      <dc:publisher>Miha Markic</dc:publisher>
      <pingback:server>http://blog.rthand.com/pingback.axd</pingback:server>
      <pingback:target>http://blog.rthand.com/post.aspx?id=242012c5-80c2-44d4-9924-1d27842e99e7</pingback:target>
      <slash:comments>5</slash:comments>
      <trackback:ping>http://blog.rthand.com/trackback.axd?id=242012c5-80c2-44d4-9924-1d27842e99e7</trackback:ping>
      <wfw:comment>http://blog.rthand.com/post/2009/09/13/Investigating-Windows-BSOD-cause-for-dummies.aspx#comment</wfw:comment>
      <wfw:commentRss>http://blog.rthand.com/syndication.axd?post=242012c5-80c2-44d4-9924-1d27842e99e7</wfw:commentRss>
    <feedburner:origLink>http://blog.rthand.com/post.aspx?id=242012c5-80c2-44d4-9924-1d27842e99e7</feedburner:origLink></item>
  </channel>
</rss>
