﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>Cool Programming</title>
    <link>http://www.kbcafe.com/csharp/</link>
    <description>Cool Programming Tips with C#</description>
    <managingEditor>webmaster@kbcafe.com</managingEditor>
    <webMaster>webmaster@kbcafe.com</webMaster>
    <pubDate>Mon, 26 Feb 2007 16:52:53 GMT</pubDate>
    <lastBuildDate>Mon, 26 Feb 2007 16:52:53 GMT</lastBuildDate>
    <copyright>Copyright 2005 Randy Charles Morin</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <url>http://www.kbcafe.com/csharp/logo.jpg</url>
      <title>Cool Programming</title>
      <link>http://www.kbcafe.com/csharp/</link>
    </image>
    <rar:archive xmlns:rar="http://tempuri.org">http://www.kbcafe.com/csharp/archive.xml</rar:archive>
    <item>
      <title>Understanding Over-design</title>
      <description>&lt;P&gt;One of the biggest problem in software development is over-design. Most programmers will often over-design their software and cause bugs in the process. The best example of this is the phone number control. Ask a programmer to develop a control that accepts phone numbers and you'll often get a control that has keystroke validation that forces the phone number to the standard (xxx)-xxx-xxxx format. This is what my cellphone expects. Why is this incorrect? I can't enter extensions. I can't enter overseas phone numbers. I can't enter alpha equivalents. A simple input box that limits the length of the string to 64 characters is clearly a better solution, but most programmers will over-design on this simple task. In fact, it's a given that somebody will suggest that I'm wrong in the comments.&lt;/P&gt;</description>
      <link>http://www.kbcafe.com/csharp/?guid=20070226085213</link>
      <pubDate>Mon, 26 Feb 2007 16:52:13 GMT</pubDate>
      <guid>http://www.kbcafe.com/csharp/?guid=20070226085213</guid>
      <comments>http://www.kbcafe.com/csharp/?guid=20070226085213</comments>
      <trackback:ping xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">http://www.kbcafe.com/csharp/trackback.aspx?guid=20070226085213</trackback:ping>
      <wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/commentapi.aspx?guid=20070226085213</wfw:comment>
      <wfw:commentRSS xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/20070226085213.xml</wfw:commentRSS>
      <category>dev</category>
    </item>
    <item>
      <title>ThreadStateException in NUnit</title>
      <description>&lt;P __designer:dtid="281474976710660"&gt;I use &lt;A href="http://www.nunit.org/"&gt;NUnit&lt;/A&gt; a lot. In fact, I doubt many have written more NUnit tests than I. I think I've written about ten thousand tests. I love the entire idea of regressive unit testing. That's one reason I believe my software is less buggy than most. Unfortunately, NUnit is extremely buggy. Fortunate that it is used by very technical people, because if you wrote software this buggy for mundane users, then you'd likely have no users at all. With each version of NUnit, thousands of bugs are fixed and thousands more are introduced. I just upgraded my NUnit to the latest 2.2.9 and of course, hundreds of tests are broken. Here's a simple code fragment they broke.&lt;/P&gt;&lt;PRE __designer:dtid="281474976710661"&gt;using System;

namespace TestHarness
{

[NUnit.Framework.TestFixture()]
public class UITests
{

[NUnit.Framework.Test]
public void SurfHomepage()
{
  System.Windows.Forms.WebBrowser browser 
    = new System.Windows.Forms.WebBrowser();
  browser.Navigate("http://www.r-mail.org");
  while (browser.ReadyState != 
    System.Windows.Forms.WebBrowserReadyState.Complete)
  {
    System.Windows.Forms.Application.DoEvents();
  }
}

}

}&lt;/PRE&gt;
&lt;P __designer:dtid="281474976710662"&gt;What the NUnit team did was hardcode NUnit to use the MTA apartment thread, which no longer works with the .NET 2.0 WebBrowser object that requires STA. If you run this test, then you get the following error.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;TestHarness.UITests.SurfHomepage : System.Threading.ThreadStateException : ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Another problem with NUnit is that its horribly documenting. Searching for a solution to this problem was extremely difficult. A dozen of red herrings before I found &lt;A href="http://www.testdriven.com/modules/newbb/viewtopic.php?topic_id=3983&amp;amp;forum=6"&gt;two&lt;/A&gt; &lt;A href="http://www.testdriven.com/modules/newbb/viewtopic.php?topic_id=3886&amp;amp;forum=6"&gt;threads&lt;/A&gt; that vaguely identified the solution. Which I'll document better here.&lt;/P&gt;
&lt;P&gt;The solution is to create a .config file for your tests. Follow these steps.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Locate NUnitTests.config in Program Files\NUnit\bin.&lt;/LI&gt;
&lt;LI&gt;Copy this file to the same folder as your .nunit file.&lt;/LI&gt;
&lt;LI&gt;Rename this file to match your .nunit file. If your .nunit file is test.nunit, then rename this .config to test.config.&lt;/LI&gt;
&lt;LI&gt;Now open up the new .config file and&amp;nbsp;locate the&amp;nbsp;ApartmentState parameters. &lt;/LI&gt;
&lt;LI&gt;Change this parameter from MTA to STA.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;If you are using the NUnit console instead of the NUnit GUI, then local the .config file in the same folder as your test DLL and rename it accordingly.&lt;/P&gt;</description>
      <link>http://www.kbcafe.com/csharp/?guid=20070224120142</link>
      <pubDate>Sat, 24 Feb 2007 20:01:42 GMT</pubDate>
      <guid>http://www.kbcafe.com/csharp/?guid=20070224120142</guid>
      <comments>http://www.kbcafe.com/csharp/?guid=20070224120142</comments>
      <trackback:ping xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">http://www.kbcafe.com/csharp/trackback.aspx?guid=20070224120142</trackback:ping>
      <wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/commentapi.aspx?guid=20070224120142</wfw:comment>
      <wfw:commentRSS xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/20070224120142.xml</wfw:commentRSS>
      <category>nunit</category>
      <category>c#</category>
      <category>ttd</category>
      <category>test</category>
    </item>
    <item>
      <title>Register Express Again Please!</title>
      <description>I use Visual C# Express, Visual Web Express and SQL Server Express quite a bit. Lately, I've notice that I've had to again re-register all my express software. In some cases, I've had the software installed for more than a year and I must have previously registered the software. There appears to be a registration problem with the Express line of software that causes you to have to re-register at times.</description>
      <link>http://www.kbcafe.com/csharp/?guid=20070222172009</link>
      <pubDate>Fri, 23 Feb 2007 01:20:09 GMT</pubDate>
      <guid>http://www.kbcafe.com/csharp/?guid=20070222172009</guid>
      <comments>http://www.kbcafe.com/csharp/?guid=20070222172009</comments>
      <trackback:ping xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">http://www.kbcafe.com/csharp/trackback.aspx?guid=20070222172009</trackback:ping>
      <wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/commentapi.aspx?guid=20070222172009</wfw:comment>
      <wfw:commentRSS xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/20070222172009.xml</wfw:commentRSS>
    </item>
    <item>
      <title>Geocode.ca</title>
      <description>&lt;P&gt;&lt;A href="http://geocoder.ca/"&gt;Geocode.ca&lt;/A&gt; is an awesome web service. Given various criteria, it'll return longitudes and latitudes in XML. Here's a &lt;A href="http://www.justin-cook.com/wp/2006/04/10/aspnet-get-longitude-latitude-for-a-canadian-address/"&gt;C# programming sample&lt;/A&gt;.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://geocoder.ca/?latt=45.4237332&amp;amp;longt=-75.676332&amp;amp;corner=1&amp;amp;geoit=xml&amp;amp;range=&amp;amp;reverse=Reverse+GeoCode+it%21"&gt;Reverse geocoding of 45.4237332,-75.676332&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://geocoder.ca/?latt=40.706724&amp;amp;longt=-74.006781&amp;amp;reverse=1&amp;amp;allna=1&amp;amp;geoit=xml&amp;amp;corner=1"&gt;Reverse Geocoding of 40.706724,-74.006781 in USA&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://geocoder.ca/?addresst=Cross%20Street&amp;amp;stno=8&amp;amp;city=Toronto&amp;amp;prov=ON&amp;amp;geoit=xml"&gt;8 Cross Street, Toronto, ON&lt;/A&gt; (by address)&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://geocoder.ca/?locate=200+pearl+st%2C+new+york%2C+ny&amp;amp;geoit=xml"&gt;200 pearl st, new york, ny&lt;/A&gt; (by US address)&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://geocoder.ca/?postal=K1R7S8&amp;amp;geoit=xml"&gt;K1R7S8&lt;/A&gt; (by postal code)&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://geocoder.ca/?street1=patterson&amp;amp;street2=metcalfe&amp;amp;city=ottawa&amp;amp;prov=ON&amp;amp;cross=1&amp;amp;geoit=xml"&gt;patterson and metcalfe, ottawa, ontario&lt;/A&gt; (by intersection)&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://geocoder.ca/?locate=Highway+401+%26+Yonge+Toronto&amp;amp;geoit=xml"&gt;Highway 401 &amp;amp; Yonge Toronto&lt;/A&gt; - &lt;A href="http://geocoder.ca/?locate=hwy+400+and+hwy+401+toronto&amp;amp;geoit=xml"&gt;hwy 400 and hwy 401 toronto&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://geocoder.ca/"&gt;http://geocoder.ca/&lt;/A&gt;&lt;/P&gt;</description>
      <link>http://www.kbcafe.com/csharp/?guid=20070218220059</link>
      <pubDate>Mon, 19 Feb 2007 06:00:59 GMT</pubDate>
      <guid>http://www.kbcafe.com/csharp/?guid=20070218220059</guid>
      <comments>http://www.kbcafe.com/csharp/?guid=20070218220059</comments>
      <trackback:ping xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">http://www.kbcafe.com/csharp/trackback.aspx?guid=20070218220059</trackback:ping>
      <wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/commentapi.aspx?guid=20070218220059</wfw:comment>
      <wfw:commentRSS xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/20070218220059.xml</wfw:commentRSS>
      <category>geocode</category>
    </item>
    <item>
      <title>System.UnauthorizedAccessException in IIS</title>
      <description>&lt;P&gt;The most frustrating error in ASP.NET is when you locate your Web folder outside of the wwwroot folder. If you copy file to that location, then giving the ASPNET or IUSR_XXX user access doesn't always help.&amp;nbsp; You also have to give permission to IIS_WPG. I pier developer&amp;nbsp;had this problem 3 years ago and simply couldn't find this solution even after days of research. Hopefully, this will save someone somewhere some time.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/technet/technetmag/issues/2005/01/ServingTheWeb/?topics=/technet/technetmag/issues/2005/01/ServingTheWeb"&gt;Read more here&lt;/A&gt;.&lt;/P&gt;</description>
      <link>http://www.kbcafe.com/csharp/?guid=20070218185008</link>
      <pubDate>Mon, 19 Feb 2007 02:50:08 GMT</pubDate>
      <guid>http://www.kbcafe.com/csharp/?guid=20070218185008</guid>
      <comments>http://www.kbcafe.com/csharp/?guid=20070218185008</comments>
      <trackback:ping xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">http://www.kbcafe.com/csharp/trackback.aspx?guid=20070218185008</trackback:ping>
      <wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/commentapi.aspx?guid=20070218185008</wfw:comment>
      <wfw:commentRSS xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/20070218185008.xml</wfw:commentRSS>
      <category>iis</category>
    </item>
    <item>
      <title>SQL Express Bulk Copy</title>
      <description>&lt;P&gt;Today, I exported a table via bcp from an SQL Server database to be imported into an SQL Server Express database. A couple hints if you are doing this.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You have to enable Named Pipes as the default installation of SQL Express does not have this enabled.&lt;/LI&gt;
&lt;LI&gt;You have to specify the server as -S.\SQLExpress&lt;/LI&gt;&lt;/UL&gt;</description>
      <link>http://www.kbcafe.com/csharp/?guid=20070218150524</link>
      <pubDate>Sun, 18 Feb 2007 23:05:24 GMT</pubDate>
      <guid>http://www.kbcafe.com/csharp/?guid=20070218150524</guid>
      <comments>http://www.kbcafe.com/csharp/?guid=20070218150524</comments>
      <trackback:ping xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">http://www.kbcafe.com/csharp/trackback.aspx?guid=20070218150524</trackback:ping>
      <wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/commentapi.aspx?guid=20070218150524</wfw:comment>
      <wfw:commentRSS xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.kbcafe.com/csharp/20070218150524.xml</wfw:commentRSS>
      <category>sqlserver</category>
      <category>bcp</category>
    </item>
  </channel>
</rss>
