<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" 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:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>.net</title>
        <link>http://geekswithblogs.net/malloc/category/6435.aspx</link>
        <description>.net</description>
        <language>en-US</language>
        <copyright>malloc();</copyright>
        <managingEditor>malloc@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Silicon Valley Code Camp October 27-28</title>
            <link>http://geekswithblogs.net/malloc/archive/2007/08/20/Silicon-Valley-Code-Camp-October-27-28.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://www.SiliconValley-Codecamp.com/Home.aspx"&gt;&lt;img alt="CodeCamp at FootHill College.  Click Here for Details and Registration" src="http://www.siliconvalley-codecamp.com/DisplayAd.ashx?ImageType=4" border="0" longdesc="" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Time to register again for this years Code Camp.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:7798a33d-996b-40cc-9c29-5a2d6eba440e" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/.net" rel="tag"&gt;.net&lt;/a&gt;, &lt;a href="http://technorati.com/tags/code%20camp" rel="tag"&gt;code camp&lt;/a&gt;, &lt;a href="http://technorati.com/tags/silicon%20valley" rel="tag"&gt;silicon valley&lt;/a&gt;, &lt;a href="http://technorati.com/tags/programming" rel="tag"&gt;programming&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=114831"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=114831" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/malloc/aggbug/114831.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>malloc();</dc:creator>
            <guid>http://geekswithblogs.net/malloc/archive/2007/08/20/Silicon-Valley-Code-Camp-October-27-28.aspx</guid>
            <pubDate>Tue, 21 Aug 2007 04:20:01 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/malloc/comments/114831.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/malloc/archive/2007/08/20/Silicon-Valley-Code-Camp-October-27-28.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/malloc/comments/commentRss/114831.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/malloc/services/trackbacks/114831.aspx</trackback:ping>
        </item>
        <item>
            <title>Picking a great project codename</title>
            <link>http://geekswithblogs.net/malloc/archive/2007/07/09/Picking-a-great-project-codename.aspx</link>
            <description>&lt;p&gt;Back in February we (me and one other co-worker) started on a new project. We were both very excited about the project (and still are) so we &lt;strong&gt;needed&lt;/strong&gt; to come up with a great codename.&lt;/p&gt; &lt;p&gt;Since we were both Transformers fans as kids we named all the different components after &lt;a href="http://en.wikipedia.org/wiki/The_Transformers_%28animated_series%29_characters"&gt;Transformers characters&lt;/a&gt;. And now in July we are almost done with the project, so today we all went to the noon showing of the Transformers movie.&lt;/p&gt; &lt;p&gt;Mini-movie-review: if you can get passed the GM advertising, it is an excellent summer action blockbuster movie.&lt;/p&gt; &lt;p&gt;Was a great break from work, and also great to know your work is appreciated. But now that the project is coming to the end, the worst part is approaching. We will have to start calling it by its "public" name and can no longer complain about bugs in &lt;a href="http://en.wikipedia.org/wiki/Snarl_%28Transformers%29"&gt;Snarl&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Grimlock"&gt;Grimlock&lt;/a&gt;, or &lt;a href="http://en.wikipedia.org/wiki/Unicron"&gt;Unicron&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;If your in the Bay Area and looking for a new job and like .NET, TDD, Transformers, and wants to work with web services and/or financial data you should get in &lt;a href="http://geekswithblogs.net/malloc/contact.aspx"&gt;contact with me&lt;/a&gt;.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;EOF&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:57851bd4-3126-4f39-8cc8-4036401481b9" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/transformers%20codename%20projects" rel="tag"&gt;transformers codename projects&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=113814"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=113814" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/malloc/aggbug/113814.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>malloc();</dc:creator>
            <guid>http://geekswithblogs.net/malloc/archive/2007/07/09/Picking-a-great-project-codename.aspx</guid>
            <pubDate>Tue, 10 Jul 2007 04:12:48 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/malloc/comments/113814.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/malloc/archive/2007/07/09/Picking-a-great-project-codename.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/malloc/comments/commentRss/113814.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/malloc/services/trackbacks/113814.aspx</trackback:ping>
        </item>
        <item>
            <title>MbUnit 2.4</title>
            <link>http://geekswithblogs.net/malloc/archive/2007/05/26/MbUnit-2.4.aspx</link>
            <description>&lt;p&gt;Thanks to &lt;a href="http://weblogs.asp.net/astopford/"&gt;Andrew Stopford&lt;/a&gt; and everyone else who works on MbUnit development. &lt;a href="http://weblogs.asp.net/astopford/archive/2007/05/24/mbunit-2-4-rtm.aspx"&gt;MbUnit 2.4 was just released&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;If you are not unit testing or practicing TDD in your projects, I don't know how you could choose plain old NUnit over MbUnit. If you are using regular NUnit it is very simple to convert your projects MbUnit, they use the same [Test] attribute. &lt;/p&gt; &lt;p&gt;MbUnit has:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Row Testing:  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;[RowTest]
[Row(&lt;span style="color: #006080"&gt;"Hello"&lt;/span&gt;)]
[Row(&lt;span style="color: #006080"&gt;"Goodbye"&lt;/span&gt;)]
&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; TestString( &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; myString )
{
    &lt;span style="color: #008000"&gt;// do your tests in here...&lt;/span&gt;
}&lt;/pre&gt;&lt;/div&gt;More row testing details &lt;a href="http://haacked.com/archive/2004/10/20/Row_Based_Testing.aspx"&gt;here&lt;/a&gt;. 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://haacked.com/archive/2007/05/10/productive-unit-testing-with-specialized-assertion-classes-in-mbunit.aspx"&gt;Specialized Assertions&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;Database rollback. The unit testing gods say that there should be absolutly no DB access in unit tests, but there are some times when I cannot avoid it. With the rollback attribute I don't have to worry about cleaning up the database after my test runs 
&lt;/li&gt;&lt;li&gt;Being able to test private methods. (see Vadim Kreynin's articles &lt;a href="http://vadim-net.blogspot.com/2007/04/testing-non-public-members-with-mbunit.html"&gt;here&lt;/a&gt; and &lt;a href="http://vadim-net.blogspot.com/2007/04/testing-non-public-members-with-mbunit_29.html"&gt;here&lt;/a&gt;). *
&lt;/li&gt;&lt;li&gt;&lt;a href="http://haacked.com/archive/2007/04/27/extract-embedded-resources-with-an-attribute-in-mbunit.aspx"&gt;Extract Embedded Resources With An Attribute In MbUnit&lt;/a&gt;. No more dealing with test file directories or setting the correct path in the [SetUp] methods!
&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.mertner.com/confluence/display/MbUnit/RepeatAttribute"&gt;RepeatAttribute&lt;/a&gt;. Run a specific test multiple times in a row.
&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.mertner.com/confluence/display/MbUnit/ThreadedRepeatAttribute"&gt;ThreadedRepeatAttribute&lt;/a&gt;. Run a specific test on multiple threads.
&lt;/li&gt;&lt;li&gt;etc. &lt;a title="http://www.mbunit.com/" href="http://www.mbunit.com/"&gt;http://www.mbunit.com/&lt;/a&gt; for all the details.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt; * I have been using the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx"&gt;InternalsVisibleTo&lt;/a&gt; assembly attribute to accomplish this for a little while now. It gets the job done nicely and has allowed complete separation of our unit tests into a separate assembly. It does require you to change method signatures to &lt;font color="#0000ff"&gt;internal&lt;/font&gt; instead of &lt;font color="#0000ff"&gt;private&lt;/font&gt;, OO purists might feel dirty doing this. Derik Whittaker had a good &lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2007/04/09/internalsvisibleto-testing-internal-methods-in-net-2-0.aspx"&gt;example&lt;/a&gt; on how the attribute should be used.&lt;/p&gt;
&lt;p&gt;EOF&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:12c7f14b-dc95-4613-bc41-8c6f65f86adb" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/MbUnit" rel="tag"&gt;MbUnit&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Unit%20Testing" rel="tag"&gt;Unit Testing&lt;/a&gt;, &lt;a href="http://technorati.com/tags/TDD" rel="tag"&gt;TDD&lt;/a&gt;, &lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=112783"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=112783" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/malloc/aggbug/112783.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>malloc();</dc:creator>
            <guid>http://geekswithblogs.net/malloc/archive/2007/05/26/MbUnit-2.4.aspx</guid>
            <pubDate>Sun, 27 May 2007 02:13:41 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/malloc/comments/112783.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/malloc/archive/2007/05/26/MbUnit-2.4.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/malloc/comments/commentRss/112783.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/malloc/services/trackbacks/112783.aspx</trackback:ping>
        </item>
        <item>
            <title>Why I don't mind catching the type Exception</title>
            <link>http://geekswithblogs.net/malloc/archive/2007/04/05/110966.aspx</link>
            <description>&lt;p&gt;My team has been working on and off all week trying to find out why one of our windows services was crashing at the same time every day with a very unhelpful eventlog message.&lt;/p&gt; &lt;p&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/malloc/6478/o_eventlog_ivoe.gif"&gt;&lt;/p&gt; &lt;p&gt;Like all good errors, a &lt;a href="http://www.google.com/search?hl=en&amp;amp;q=clr20r3+invalidoperationexception"&gt;search&lt;/a&gt; on the error message returns many results where people get the same message but for a bunch of different reasons and where many of the search result threads are left unanswered.&lt;/p&gt; &lt;p&gt;This service was first developed in .NET 1.1 way before I joined the company (only 5 months ago). It had been running without crashes on a Windows 2k machine for years. Now that we are finally throwing out our 2k systems we have migrated all our 1.1 code to 2.0 and running them on Win2k3.&lt;/p&gt; &lt;p&gt;So what does this service do? It is the final step in a data stream processing system. Here is a quick graphic to display the flow:&lt;br&gt;&lt;img src="http://geekswithblogs.net/images/geekswithblogs_net/malloc/6478/o_flow.gif"&gt;&lt;br&gt;As you can see, this service does the easy part of the process. Read from the MSMQ, spawn a&amp;nbsp;new thread (thread pooled) for each message to take the SQL string value, connect to the DB, and execute the SQL. The thread does those simple steps and then dies off. The main thread continues to wait for new MSMQ messages and spawn new threads as they come in. &lt;/p&gt; &lt;p&gt;At first look of the code there was nothing obvious wrong. No "important" code missing try's or catch's. And all of the try/catches has logging code to tell us (using the eventlog) if anything goes wrong. However, the eventlog would only have the '.NET Runtime 2.0 Error Reporting' message after the crash and none of our messages.&lt;/p&gt; &lt;p&gt;After looking closer at all of the code, we found the problem. Here is a snippet of what ended up being the problem code. It is code that runs on the worker threads from the thread pool. &lt;/p&gt; &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt; &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Class&lt;/span&gt; DumpInThread&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; Query &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.&lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; Message &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Messaging.Message&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; objConnection &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Data.SqlClient.SqlConnection&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #008000"&gt;'======================================================================================&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Dump(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; StateInfo &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.&lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;Do&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Until&lt;/span&gt; GetNewConnection() = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;Loop&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;         InsertMessage(Query)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     &lt;span style="color: #008000"&gt;'======================================================================================&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; GetNewConnection() &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.&lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;             objConnection = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; System.Data.SqlClient.SqlConnection(&lt;span style="color: #006080"&gt;"SqlServer"&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;             objConnection.Open()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;Catch&lt;/span&gt; Exception &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Data.SqlClient.SqlException&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  18:&lt;/span&gt;             SharedEventLog.WriteEntry(&lt;span style="color: #006080"&gt;"Could not obtain connection "&lt;/span&gt; &amp;amp; Connection &amp;amp; &lt;span style="color: #006080"&gt;":"&lt;/span&gt; &amp;amp; Exception.Message, System.Diagnostics.EventLogEntryType.&lt;span style="color: #0000ff"&gt;Error&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  19:&lt;/span&gt;             objMessageQueue.Send(Message)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  20:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;False&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  21:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  22:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Function&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Look &lt;a href="http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.open(vs.80).aspx"&gt;here&lt;/a&gt; (or just continue reading) to find out what we first realized. SqlConnection.Open() can throw either a a &lt;a href="http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlexception(vs.80).aspx"&gt;SqlException&lt;/a&gt;&amp;nbsp;or an &lt;a href="http://msdn2.microsoft.com/en-us/library/system.invalidoperationexception(vs.80).aspx"&gt;InvalidOperationException&lt;/a&gt;. To me, it makes more sense for a SqlConnection to throw a SqlException if it cannot connect to a DB, not a generic exception like InvalidOperationException. We changed the catch so it will also catch the InvalidOperationException. This stops the threads and therefor the process from crashing.&lt;/p&gt;
&lt;p&gt;The second thing to realize is that this InvalidOperationException is not new to .NET 2.0. The .NET 1.1 api docs say that the SqlConnection.Open() throws an InvalidOperationException. This code has been incorrect since the day it was written. One thing that has changes between 1.1 and 2.0 has been the handling of threads. In 2.0 if a thread has an uncaught exception it will crash the entire process instead of being quietly swallowed.&lt;/p&gt;
&lt;p&gt;"But didn't you say the process crashed at the same time every day, how does that factor into the fix?" Yes this process would crash daily at 2:14pm, and after all of this I still have no idea why :-). We could not find any jobs using the same DB at this time that may have caused a connection to timeout. There is not a large burst of messages at that time, it is actually one of the more quieter times in the day. But I know that the new catch block fixes the crash, and makes the code much more reliable then it has been since it was born. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;EOF&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:a878a834-4c42-4596-b680-6b698ea95d93" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;, &lt;a href="http://technorati.com/tags/exception" rel="tag"&gt;exception&lt;/a&gt;, &lt;a href="http://technorati.com/tags/threads" rel="tag"&gt;threads&lt;/a&gt;, &lt;a href="http://technorati.com/tags/windows%20service" rel="tag"&gt;windows service&lt;/a&gt;, &lt;a href="http://technorati.com/tags/clr20r3" rel="tag"&gt;clr20r3&lt;/a&gt;, &lt;a href="http://technorati.com/tags/debugging" rel="tag"&gt;debugging&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=110966"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=110966" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/malloc/aggbug/110966.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>malloc();</dc:creator>
            <guid>http://geekswithblogs.net/malloc/archive/2007/04/05/110966.aspx</guid>
            <pubDate>Fri, 06 Apr 2007 04:41:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/malloc/comments/110966.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/malloc/archive/2007/04/05/110966.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/malloc/comments/commentRss/110966.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/malloc/services/trackbacks/110966.aspx</trackback:ping>
        </item>
    </channel>
</rss>