<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/"><channel><title>C#</title><link>http://blogs.acceleration.net/ryan/category/23.aspx</link><description>Things dealing with C#.</description><managingEditor>Ryan</managingEditor><dc:language>en-US</dc:language><generator>.Text Version 0.95.2004.102</generator><item><dc:creator>Ryan</dc:creator><title>Server found request content type to be '', but expected 'text/xml'.</title><link>http://blogs.acceleration.net/ryan/archive/2005/11/10/2800.aspx</link><pubDate>Thu, 10 Nov 2005 17:43:00 GMT</pubDate><guid>http://blogs.acceleration.net/ryan/archive/2005/11/10/2800.aspx</guid><description>&lt;p&gt;I got this error when calling a C# web service from javascript.  With a message like that, you'd think
		there was a problem with the Content-Type on my HTTP request.
	 &lt;/p&gt;
	 &lt;p&gt;Using the fine &lt;a href="http://livehttpheaders.mozdev.org/"&gt;LiveHTTPHeaders&lt;/a&gt; 
		Firefox extension, I saw in the headers:
	 &lt;/p&gt;&lt;div&gt;Content-Type: text/xml; charset=UTF-8&lt;/div&gt;
	 Ok, so the content-type seemed ok, and it was time to start looking at my most recent changes to see where the bug was.
  
	 &lt;p&gt;
		After a bit of hunting, I found the problem.  My web service had an &lt;code&gt;int&lt;/code&gt; parameter, and I was passing in 't1245'.  That 
		caused a casting error, which .NET cleverly reported back as a problem with the content-type.&lt;/p&gt;
	 &lt;p&gt;Moral of the story: make your error messages meaningful.&lt;/p&gt;&lt;img src ="http://blogs.acceleration.net/ryan/aggbug/2800.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>I got this error when calling a C# web service from javascript.  With a message like that, you'd think
		there was a problem with the Content-Type on my HTTP request.
	 </p>
	 <p>Using the fine <a href="http://livehttpheaders.mozdev.org/">LiveHTTPHeaders</a> 
		Firefox extension, I saw in the headers:
	 </p><div>Content-Type: text/xml; charset=UTF-8</div>
	 Ok, so the content-type seemed ok, and it was time to start looking at my most recent changes to see where the bug was.
  
	 <p>
		After a bit of hunting, I found the problem.  My web service had an <code>int</code> parameter, and I was passing in 't1245'.  That 
		caused a casting error, which .NET cleverly reported back as a problem with the content-type.</p>
	 <p>Moral of the story: make your error messages meaningful.</p><img src ="http://blogs.acceleration.net/ryan/aggbug/2800.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Ryan</dc:creator><title>XmlSerializer eats default attributes</title><link>http://blogs.acceleration.net/ryan/archive/2005/10/17/2793.aspx</link><pubDate>Mon, 17 Oct 2005 16:06:00 GMT</pubDate><guid>http://blogs.acceleration.net/ryan/archive/2005/10/17/2793.aspx</guid><description>&lt;p&gt;
		So, I'm still working with XML generation, and I discovered an interesting design choice made by the writers of &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlserializationxmlserializerclasstopic.asp"&gt;XmlSerializer&lt;/a&gt;.  
		My &lt;a href="http://blogs.acceleration.net/ryan/archive/2005/10/16/2792.aspx"&gt;efforts from yesterday&lt;/a&gt; were so I could use the XmlSerializer to generate
		flawless XML from C# objects, without going through the bother of string manipulation.  The XML it generates is well-formed, but it was leaving off an attribute ("Version"), and 
		I wasn't sure why.  I googled around and found another dev with the same problem.  &lt;a href="http://pluralsight.com/blogs/craig/"&gt;Craig Andera&lt;/a&gt;'s post 
		"&lt;a href="http://pluralsight.com/blogs/craig/archive/2004/07/27/1736.aspx"&gt;DefaultValue and XmlSerializer Don't Mix?&lt;/a&gt;" has a quick reproduction.
	 &lt;/p&gt;
	 &lt;p&gt;
		If you have an attribute with a default value defined in the DTD/XSD, and the C# variable representing that attribute has that value, then the 
		XmlSerializer chooses not to render the attribute.  Anyone reading the XML &lt;i&gt;must&lt;/i&gt; be using the same DTD/XSD, and they already know the default value, 
		so why waste bandwidth/space by rendering that attribute?  
	 &lt;/p&gt;
	 &lt;p&gt;
		Well, when the reader of my XML is using that missing "Version" attribute as a key for how it should process my XML, it makes a big difference.  Based on the 
		error message from the vendor, I think they are switching on that "Version" to pick a DTD, then validating against that and processing the request.
		It would be nice to have some kind of "RenderDefaultAttributesAnyway" flag I could set before serializing.  In the end I just changed the DTD to 
		remove the default value, and all was well.
	 &lt;/p&gt;&lt;img src ="http://blogs.acceleration.net/ryan/aggbug/2793.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>
		So, I'm still working with XML generation, and I discovered an interesting design choice made by the writers of <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlserializationxmlserializerclasstopic.asp">XmlSerializer</a>.  
		My <a href="http://blogs.acceleration.net/ryan/archive/2005/10/16/2792.aspx">efforts from yesterday</a> were so I could use the XmlSerializer to generate
		flawless XML from C# objects, without going through the bother of string manipulation.  The XML it generates is well-formed, but it was leaving off an attribute ("Version"), and 
		I wasn't sure why.  I googled around and found another dev with the same problem.  <a href="http://pluralsight.com/blogs/craig/">Craig Andera</a>'s post 
		"<a href="http://pluralsight.com/blogs/craig/archive/2004/07/27/1736.aspx">DefaultValue and XmlSerializer Don't Mix?</a>" has a quick reproduction.
	 </p>
	 <p>
		If you have an attribute with a default value defined in the DTD/XSD, and the C# variable representing that attribute has that value, then the 
		XmlSerializer chooses not to render the attribute.  Anyone reading the XML <i>must</i> be using the same DTD/XSD, and they already know the default value, 
		so why waste bandwidth/space by rendering that attribute?  
	 </p>
	 <p>
		Well, when the reader of my XML is using that missing "Version" attribute as a key for how it should process my XML, it makes a big difference.  Based on the 
		error message from the vendor, I think they are switching on that "Version" to pick a DTD, then validating against that and processing the request.
		It would be nice to have some kind of "RenderDefaultAttributesAnyway" flag I could set before serializing.  In the end I just changed the DTD to 
		remove the default value, and all was well.
	 </p><img src ="http://blogs.acceleration.net/ryan/aggbug/2793.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Ryan</dc:creator><title>Because acronyms are fun</title><link>http://blogs.acceleration.net/ryan/archive/2005/10/16/2792.aspx</link><pubDate>Sun, 16 Oct 2005 15:39:00 GMT</pubDate><guid>http://blogs.acceleration.net/ryan/archive/2005/10/16/2792.aspx</guid><description>&lt;p&gt;
		I've started to implement a web service, sending and receiving XML snippets to a vendor.  I was browsing their
		documentation, and was about to start throwing together some code using string functions to build/parse the XML, and then 
		I remembered all the hubub I've heard about generating code using XML files, and figured there might be some tools out
		there to make this go a lot smoother.  The vendor was kind enough to provide a sample XML file and a Document Type Definition (DTD) file, so 
		now all I need to do is convert that to C# classes.
	 &lt;/p&gt;
	 &lt;h2&gt;First try: &lt;code&gt;xsd.exe&lt;/code&gt;&lt;/h2&gt;
	 &lt;p&gt;
		The first tool I looked at was 
		&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconXMLSchemaDefinitionToolXsdexe.asp"&gt;
		  &lt;code&gt;xsd.exe&lt;/code&gt;
		&lt;/a&gt;, a command line tool bundled with Visual Studio.  When I dug in, I see that it can:
	 &lt;/p&gt;&lt;ul&gt;
		&lt;li&gt;convert a XML Schema Definition (XSD) file into C# classes &lt;/li&gt;
		&lt;li&gt;convert a sample XML file into a XSD file, inferring and guessing as to the details &lt;/li&gt;
		&lt;li&gt;convert an External Data Representation (XDR, what the hell is that one?) file into a XSD file, inferring and 
		  guessing as to the details &lt;/li&gt;
		&lt;li&gt;generate XSD files for .NET classes in a file or assembly&lt;/li&gt;
	 &lt;/ul&gt;
	 So... no option for converting a DTD.  Ok, time to google for DTD XSD converters.
  
	 &lt;h2&gt;Second try: &lt;code&gt;dtd2xs&lt;/code&gt; and &lt;code&gt;xsd.exe&lt;/code&gt;&lt;/h2&gt;
	 &lt;p&gt;
		The first hit was &lt;a href="http://www.lumrix.de/dtd2xs.php"&gt;dtd2xs&lt;/a&gt;.  This is a Java based converter that
		can be run from the commandline, used as a library in java programs, and as an applet in webpage.  It convienently
		comes with some HTML that already has the applet set up, so I loaded up that page and tried to convert my
		DTD.  After a few seconds, I was presented with a window listing some debug info, and then a line with:
	 &lt;/p&gt;&lt;div&gt;
		******************** Copy &amp;amp; Paste ********************
	 &lt;/div&gt;
	 and nothing underneath it, where I would expect to see content to Copy and Paste.  I ran it again with the same result, and 
	 then viewed source on the frame.  The source had the XSD document in there, but wasn't being rendered because all the XML was
	 meaningless to Firefox.  I copied the content into an .xsd file, and then ran &lt;code&gt;xsd.exe&lt;/code&gt; on it.  The result?  A bunch of
	 errors about invalid references in the XSD.  Maybe I can fix the XSD file using Visual Studio's XSD tools.
	 
	 &lt;h2&gt;Third try: Visual Studio&lt;/h2&gt;
	 &lt;p&gt;
		Next, I tried to use the XSD editor in Visual Studio to see if I could correct the problem.  I messed around with the raw XML 
		of the XSD file, guessing what attributes like "ref" and "name" would mean in the context of defining data.  After messing around
		with the file, I was able to generate even less sensical errors from &lt;code&gt;xsd.exe&lt;/code&gt;.  Had I put in the time to learn the XSD
		XML dialect, then I'm sure these errors would make sense, but I've no interest in learning more XML acronyms.  There's enough of those
		in my head already.  I decided to try to build it from scratch using Visual Studio's GUI XSD editor.  
	 &lt;/p&gt;
	 &lt;p&gt;
		I dragged an "element" block from the toolbox, added some attributes, and then promptly gave up.
		The UI wasn't that great (few tooltips, ambiguous context menu options), and it wasn't clear how to do what should be simple things.
		I figure if I'm going to spend time learning how to use a tool, I'd rather use one that will be more efficient, so I'll put my effort
		into the command line tools.
	 &lt;/p&gt;
	 &lt;h2&gt;Fourth try: &lt;code&gt;xsd.exe&lt;/code&gt; again&lt;/h2&gt;
	 &lt;p&gt;
		I decided to take a different approach:
	 &lt;/p&gt;&lt;ol&gt;
		&lt;li&gt;use &lt;code&gt;xsd.exe&lt;/code&gt; to generate an XSD from my sample XML file.&lt;/li&gt;
		&lt;li&gt;use &lt;code&gt;xsd.exe&lt;/code&gt; can generate C# from that XSD.&lt;/li&gt;
	 &lt;/ol&gt;
	 This actually worked.  The result C# was very much generated code, but it had the plumbing to save/load from an XML file or string, and
	 that is the plumbing I was wanting the most.  I took a look at the XSD to glean a bit of knowledge, and started to see the gaps left
	 by inferring schema from a sample.  Default values for attributes were lost, all enumerations were lost (when an attribute's value is 
	 restricted to certain values), all the optional stuff was missing, and overall I wasn't too pleased with the results.  I could probably
	 make it work, but I'd get a much higher quality result if I could retain as much of the vendor's definition as possible.  Back to google 
	 for another dtd xsd converter.
  
	 &lt;h2&gt;Fifth try: &lt;code&gt;Xsdvalid&lt;/code&gt; and &lt;code&gt;xsd.exe&lt;/code&gt;&lt;/h2&gt;
	 &lt;p&gt;
		The next converter I found was &lt;a href="http://www.xmlmind.com/xsdvalid.html"&gt;&lt;code&gt;Xsdvalid&lt;/code&gt;&lt;/a&gt;.  This is a sub-component
		of a larger XML editor, &lt;a href="http://www.xmlmind.com/"&gt;XMLmind&lt;/a&gt; &lt;a href="http://www.xmlmind.com/xmleditor/"&gt;XML Editor&lt;/a&gt;.
		&lt;code&gt;Xsdvalid&lt;/code&gt; is another Java program (I guess Java folks love XML), able to be used as a library or from the command line.  I ran
		my DTD through it, and it came out with a much larger XSD than &lt;code&gt;dtd2xs&lt;/code&gt;.  &lt;code&gt;xsd.exe&lt;/code&gt; ran without errors on the
		first try, and the resulting C# had enums for the enumerations defined in the DTD, and seemed a lot better.  My C# is now directly based on 
		the vendor's definition, with no opportunity for me to make mistakes in translating.  
	 &lt;/p&gt;
	 &lt;h2&gt;Conclusion&lt;/h2&gt;
	 &lt;p&gt;
		I haven't actually used the generated code yet, but will be writing some unit tests momentarily for parsing/building.  I do have high hopes,
		so bless you people with XML fetishes for doing this work for me.  Also, curse you people with XML fetishes for not picking *one* 
		XML dialect to describe XML documents and causing this task in the first place.
	 &lt;/p&gt;&lt;img src ="http://blogs.acceleration.net/ryan/aggbug/2792.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>
		I've started to implement a web service, sending and receiving XML snippets to a vendor.  I was browsing their
		documentation, and was about to start throwing together some code using string functions to build/parse the XML, and then 
		I remembered all the hubub I've heard about generating code using XML files, and figured there might be some tools out
		there to make this go a lot smoother.  The vendor was kind enough to provide a sample XML file and a Document Type Definition (DTD) file, so 
		now all I need to do is convert that to C# classes.
	 </p>
	 <h2>First try: <code>xsd.exe</code></h2>
	 <p>
		The first tool I looked at was 
		<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconXMLSchemaDefinitionToolXsdexe.asp">
		  <code>xsd.exe</code>
		</a>, a command line tool bundled with Visual Studio.  When I dug in, I see that it can:
	 </p><ul>
		<li>convert a XML Schema Definition (XSD) file into C# classes </li>
		<li>convert a sample XML file into a XSD file, inferring and guessing as to the details </li>
		<li>convert an External Data Representation (XDR, what the hell is that one?) file into a XSD file, inferring and 
		  guessing as to the details </li>
		<li>generate XSD files for .NET classes in a file or assembly</li>
	 </ul>
	 So... no option for converting a DTD.  Ok, time to google for DTD XSD converters.
  
	 <h2>Second try: <code>dtd2xs</code> and <code>xsd.exe</code></h2>
	 <p>
		The first hit was <a href="http://www.lumrix.de/dtd2xs.php">dtd2xs</a>.  This is a Java based converter that
		can be run from the commandline, used as a library in java programs, and as an applet in webpage.  It convienently
		comes with some HTML that already has the applet set up, so I loaded up that page and tried to convert my
		DTD.  After a few seconds, I was presented with a window listing some debug info, and then a line with:
	 </p><div>
		******************** Copy &amp; Paste ********************
	 </div>
	 and nothing underneath it, where I would expect to see content to Copy and Paste.  I ran it again with the same result, and 
	 then viewed source on the frame.  The source had the XSD document in there, but wasn't being rendered because all the XML was
	 meaningless to Firefox.  I copied the content into an .xsd file, and then ran <code>xsd.exe</code> on it.  The result?  A bunch of
	 errors about invalid references in the XSD.  Maybe I can fix the XSD file using Visual Studio's XSD tools.
	 
	 <h2>Third try: Visual Studio</h2>
	 <p>
		Next, I tried to use the XSD editor in Visual Studio to see if I could correct the problem.  I messed around with the raw XML 
		of the XSD file, guessing what attributes like "ref" and "name" would mean in the context of defining data.  After messing around
		with the file, I was able to generate even less sensical errors from <code>xsd.exe</code>.  Had I put in the time to learn the XSD
		XML dialect, then I'm sure these errors would make sense, but I've no interest in learning more XML acronyms.  There's enough of those
		in my head already.  I decided to try to build it from scratch using Visual Studio's GUI XSD editor.  
	 </p>
	 <p>
		I dragged an "element" block from the toolbox, added some attributes, and then promptly gave up.
		The UI wasn't that great (few tooltips, ambiguous context menu options), and it wasn't clear how to do what should be simple things.
		I figure if I'm going to spend time learning how to use a tool, I'd rather use one that will be more efficient, so I'll put my effort
		into the command line tools.
	 </p>
	 <h2>Fourth try: <code>xsd.exe</code> again</h2>
	 <p>
		I decided to take a different approach:
	 </p><ol>
		<li>use <code>xsd.exe</code> to generate an XSD from my sample XML file.</li>
		<li>use <code>xsd.exe</code> can generate C# from that XSD.</li>
	 </ol>
	 This actually worked.  The result C# was very much generated code, but it had the plumbing to save/load from an XML file or string, and
	 that is the plumbing I was wanting the most.  I took a look at the XSD to glean a bit of knowledge, and started to see the gaps left
	 by inferring schema from a sample.  Default values for attributes were lost, all enumerations were lost (when an attribute's value is 
	 restricted to certain values), all the optional stuff was missing, and overall I wasn't too pleased with the results.  I could probably
	 make it work, but I'd get a much higher quality result if I could retain as much of the vendor's definition as possible.  Back to google 
	 for another dtd xsd converter.
  
	 <h2>Fifth try: <code>Xsdvalid</code> and <code>xsd.exe</code></h2>
	 <p>
		The next converter I found was <a href="http://www.xmlmind.com/xsdvalid.html"><code>Xsdvalid</code></a>.  This is a sub-component
		of a larger XML editor, <a href="http://www.xmlmind.com/">XMLmind</a> <a href="http://www.xmlmind.com/xmleditor/">XML Editor</a>.
		<code>Xsdvalid</code> is another Java program (I guess Java folks love XML), able to be used as a library or from the command line.  I ran
		my DTD through it, and it came out with a much larger XSD than <code>dtd2xs</code>.  <code>xsd.exe</code> ran without errors on the
		first try, and the resulting C# had enums for the enumerations defined in the DTD, and seemed a lot better.  My C# is now directly based on 
		the vendor's definition, with no opportunity for me to make mistakes in translating.  
	 </p>
	 <h2>Conclusion</h2>
	 <p>
		I haven't actually used the generated code yet, but will be writing some unit tests momentarily for parsing/building.  I do have high hopes,
		so bless you people with XML fetishes for doing this work for me.  Also, curse you people with XML fetishes for not picking *one* 
		XML dialect to describe XML documents and causing this task in the first place.
	 </p><img src ="http://blogs.acceleration.net/ryan/aggbug/2792.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Ryan</dc:creator><title>Remote XUL and ASP.NET</title><link>http://blogs.acceleration.net/ryan/archive/2005/10/04/2782.aspx</link><pubDate>Tue, 04 Oct 2005 18:21:00 GMT</pubDate><guid>http://blogs.acceleration.net/ryan/archive/2005/10/04/2782.aspx</guid><description>&lt;p&gt;
         I've now gotten permission to use XUL for another client, and this time around, 
         I'm trying it a little differently.
      &lt;/p&gt;
      &lt;p&gt;
         Rather than serving up a &lt;code&gt;.xul&lt;/code&gt; file, and doing everything with 
         overlays, DOM manipulation, and XBL, I'm serving up a &lt;code&gt;.aspx&lt;/code&gt; file, 
         setting its content-type to &lt;code&gt;application/vnd.mozilla.xul+xml&lt;/code&gt;, and 
         then using ASP.NET to render XUL instead of HTML. Jeb (do you have a link, 
         Jeb?) said he was creating XUL apps this way using JSP, so I figured I'd give 
         it a try. So far I like it. This method lets me lean on my ASP.NET skills while 
         I build up the XUL skills.
      &lt;/p&gt;
      &lt;h2&gt;How I have it set up:&lt;/h2&gt;
      &lt;p&gt;
         &lt;/p&gt;&lt;ul&gt;
            &lt;li&gt;
               One &lt;code&gt;.aspx&lt;/code&gt; page per XUL layout, using &lt;code&gt;&amp;lt;html:a&amp;gt;&lt;/code&gt; tags 
               to navigate between them.&lt;/li&gt;
            &lt;li&gt;
               One ASP.NET user control is on each page, ensuring all XUL layouts have the 
               same template and include the same javascript and css files. I had tried do 
               this with &lt;a href="http://www.xulplanet.com/forum/viewtopic.php?t=844"&gt;overlays&lt;/a&gt;, 
               but didn't have much luck.
            &lt;/li&gt;
            &lt;li&gt;
               A few &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebIHttpHandlerClassTopic.asp"&gt;
                  IHttpHandler&lt;/a&gt;s to send RDF to my XUL, and &lt;a href="http://www.crockford.com/JSON/index.html"&gt;
                  JSON&lt;/a&gt; to my javascript.
            &lt;/li&gt;
            &lt;li&gt;
               A few webservices that get called by my javascript, and the work is done in C#.&lt;/li&gt;
         &lt;/ul&gt;
         This seems to work pretty well. The UI and the business logic is completely 
         seperate, and by using RDF I can take advantage of XUL templates to do lots of 
         nifty things on the client.
      
      &lt;p&gt;
         For now, I'm only using this on applications that require windows 
         authentication to access the site, so to access the web services you'll need to 
         be logged in. Security is still a concern, though, and eventually I'll have to 
         expose some of these web services to wild. I've been considering some token 
         system where the server passes a token to the client when it renders the xul 
         aspx page, and then the javascript passes that token to the web services, but I 
         haven't fleshed anything out yet.
      &lt;/p&gt;&lt;img src ="http://blogs.acceleration.net/ryan/aggbug/2782.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>
         I've now gotten permission to use XUL for another client, and this time around, 
         I'm trying it a little differently.
      </p>
      <p>
         Rather than serving up a <code>.xul</code> file, and doing everything with 
         overlays, DOM manipulation, and XBL, I'm serving up a <code>.aspx</code> file, 
         setting its content-type to <code>application/vnd.mozilla.xul+xml</code>, and 
         then using ASP.NET to render XUL instead of HTML. Jeb (do you have a link, 
         Jeb?) said he was creating XUL apps this way using JSP, so I figured I'd give 
         it a try. So far I like it. This method lets me lean on my ASP.NET skills while 
         I build up the XUL skills.
      </p>
      <h2>How I have it set up:</h2>
      <p>
         </p><ul>
            <li>
               One <code>.aspx</code> page per XUL layout, using <code>&lt;html:a&gt;</code> tags 
               to navigate between them.</li>
            <li>
               One ASP.NET user control is on each page, ensuring all XUL layouts have the 
               same template and include the same javascript and css files. I had tried do 
               this with <a href="http://www.xulplanet.com/forum/viewtopic.php?t=844">overlays</a>, 
               but didn't have much luck.
            </li>
            <li>
               A few <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebIHttpHandlerClassTopic.asp">
                  IHttpHandler</a>s to send RDF to my XUL, and <a href="http://www.crockford.com/JSON/index.html">
                  JSON</a> to my javascript.
            </li>
            <li>
               A few webservices that get called by my javascript, and the work is done in C#.</li>
         </ul>
         This seems to work pretty well. The UI and the business logic is completely 
         seperate, and by using RDF I can take advantage of XUL templates to do lots of 
         nifty things on the client.
      
      <p>
         For now, I'm only using this on applications that require windows 
         authentication to access the site, so to access the web services you'll need to 
         be logged in. Security is still a concern, though, and eventually I'll have to 
         expose some of these web services to wild. I've been considering some token 
         system where the server passes a token to the client when it renders the xul 
         aspx page, and then the javascript passes that token to the web services, but I 
         haven't fleshed anything out yet.
      </p><img src ="http://blogs.acceleration.net/ryan/aggbug/2782.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Ryan</dc:creator><title>C#, I hate you</title><link>http://blogs.acceleration.net/ryan/archive/2005/06/06/1218.aspx</link><pubDate>Mon, 06 Jun 2005 15:55:00 GMT</pubDate><guid>http://blogs.acceleration.net/ryan/archive/2005/06/06/1218.aspx</guid><description>&lt;div class="Code"&gt;
      &lt;table class="dp-c" border="0" cellpadding="0" cellspacing="0" id="Table1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="keyword"&gt;public&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="keyword"&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="keyword"&gt;readonly&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="keyword"&gt;string&lt;/span&gt;&lt;span&gt; Foo = &lt;/span&gt;&lt;span class="string"&gt;"bar"&lt;/span&gt;&lt;span&gt;; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;&lt;span class="keyword"&gt;public&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="keyword"&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="keyword"&gt;void&lt;/span&gt;&lt;span&gt; Main(){ &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;  &lt;span class="keyword"&gt;string&lt;/span&gt;&lt;span&gt; f = &lt;/span&gt;&lt;span class="string"&gt;"bar"&lt;/span&gt;&lt;span&gt;; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;  &lt;span class="keyword"&gt;switch&lt;/span&gt;&lt;span&gt;(f){ &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;    &lt;span class="keyword"&gt;case&lt;/span&gt;&lt;span&gt; Foo: &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;      &lt;span class="keyword"&gt;break&lt;/span&gt;&lt;span&gt;; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;  } &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;} &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
   
      error CS0150: A constant value is expected&lt;br /&gt;
      Cannot convert expression of type 'string' to type 'string'
   &lt;/div&gt;
   &lt;p&gt;
      I have a &lt;code&gt;public static readonly string&lt;/code&gt;, and I want to use it as a case in a switch statement, as above.  Unfortunately for me, C# doesn't
      think a &lt;code&gt;public &lt;strong&gt;static readonly&lt;/strong&gt; string&lt;/code&gt; is a constant value.  I guess it's not constant, as it changes from its compile time 
      value (null?) to its runtime value ("bar") once it gets referenced.  This is retarded.  What if I wanted to store constant values in the
      web|app.config?  Those aren't determined until runtime when I pull them out of &lt;code&gt;ConfigurationSettings.AppSettings&lt;/code&gt;.
   &lt;/p&gt;
   &lt;p&gt;
      Oh wait, that is such a time-saver!  Now I don't have to even &lt;em&gt;consider&lt;/em&gt; solutions using runtime constants in case statements.
      Thanks, C# language developers, you've limited my options once again, steering my foolish code down the path you know is best!
   &lt;/p&gt;&lt;img src ="http://blogs.acceleration.net/ryan/aggbug/1218.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><div class="Code">
      <table class="dp-c" border="0" cellpadding="0" cellspacing="0" id="Table1"><tbody><tr></tr><tr><td class="line"><span></span><span class="keyword">public</span><span> </span><span class="keyword">static</span><span> </span><span class="keyword">readonly</span><span> </span><span class="keyword">string</span><span> Foo = </span><span class="string">"bar"</span><span>; </span></td></tr><tr><td class="line"> </td></tr><tr><td class="line"><span class="keyword">public</span><span> </span><span class="keyword">static</span><span> </span><span class="keyword">void</span><span> Main(){ </span></td></tr><tr><td class="line">  <span class="keyword">string</span><span> f = </span><span class="string">"bar"</span><span>; </span></td></tr><tr><td class="line">  <span class="keyword">switch</span><span>(f){ </span></td></tr><tr><td class="line">    <span class="keyword">case</span><span> Foo: </span></td></tr><tr><td class="line">      <span class="keyword">break</span><span>; </span></td></tr><tr><td class="line">  } </td></tr><tr><td class="line">} </td></tr></tbody></table>
   
      error CS0150: A constant value is expected<br />
      Cannot convert expression of type 'string' to type 'string'
   </div>
   <p>
      I have a <code>public static readonly string</code>, and I want to use it as a case in a switch statement, as above.  Unfortunately for me, C# doesn't
      think a <code>public <strong>static readonly</strong> string</code> is a constant value.  I guess it's not constant, as it changes from its compile time 
      value (null?) to its runtime value ("bar") once it gets referenced.  This is retarded.  What if I wanted to store constant values in the
      web|app.config?  Those aren't determined until runtime when I pull them out of <code>ConfigurationSettings.AppSettings</code>.
   </p>
   <p>
      Oh wait, that is such a time-saver!  Now I don't have to even <em>consider</em> solutions using runtime constants in case statements.
      Thanks, C# language developers, you've limited my options once again, steering my foolish code down the path you know is best!
   </p><img src ="http://blogs.acceleration.net/ryan/aggbug/1218.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Ryan</dc:creator><title>log4net revisited</title><link>http://blogs.acceleration.net/ryan/archive/2005/05/31/1174.aspx</link><pubDate>Tue, 31 May 2005 19:09:00 GMT</pubDate><guid>http://blogs.acceleration.net/ryan/archive/2005/05/31/1174.aspx</guid><description>&lt;p&gt;
      It's been awhile since I wrote the &lt;a href="http://blogs.acceleration.net/ryan/articles/379.aspx"&gt;walkthrough&lt;/a&gt;, and I've come across
      a few more problems and solutions.  Most of the walkthrough still applies, but here are two tips to make it even easier.
   &lt;/p&gt;
   &lt;h2&gt;Connection string management&lt;/h2&gt;
   &lt;p&gt;
      The connection string for ADONetAppenders is set in the web.config.  You usually
      also have a connection string specified elsewhere for the rest of your application to use, 
      and having to specify it again is a little nasty, but not too bad.  The real problem is when
      you have a dev/test/live database setup.  You probably already have some system for swapping your main connection string.
      The solution is to set the log4net connection string on initialization, and ignore the one specified in web.config.&lt;br /&gt;
      Instead of just calling:
      &lt;/p&gt;&lt;div&gt;
      log4net.Config.DOMConfigurator.Configure();
      &lt;/div&gt;
      to initalize log4net, call this:
      &lt;div class="Code"&gt;
         &lt;table class="dp-c" border="0" cellpadding="0" cellspacing="0" id="Table1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="keyword"&gt;try&lt;/span&gt;&lt;span&gt;{ &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;   &lt;span class="comment"&gt;//configure the damn thing.&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;   log4net.Config.DOMConfigurator.Configure(); &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;   log4net.Repository.Hierarchy.Hierarchy h = LogManager.GetLoggerRepository() &lt;span class="keyword"&gt;as&lt;/span&gt;&lt;span&gt; log4net.Repository.Hierarchy.Hierarchy; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;   &lt;span class="comment"&gt;//get the ADO appender&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;   log4net.Appender.ADONetAppender ado = h.Root.GetAppender(&lt;span class="string"&gt;"ADONetAppender"&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span class="keyword"&gt;as&lt;/span&gt;&lt;span&gt; log4net.Appender.ADONetAppender; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;   ado.ConnectionString = YOUR_CONNECTION_STRING; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;   ado.ActivateOptions(); &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;   &lt;span class="keyword"&gt;return&lt;/span&gt;&lt;span&gt; conn; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;}&lt;span class="keyword"&gt;catch&lt;/span&gt;&lt;span&gt;(NullReferenceException nfe) { &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;   &lt;span class="keyword"&gt;throw&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="keyword"&gt;new&lt;/span&gt;&lt;span&gt; NullReferenceException(&lt;/span&gt;&lt;span class="string"&gt;"log4net configuration could not be completed.  \nDo you have your app.config set up properly?"&lt;/span&gt;&lt;span&gt;, nfe); &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="line"&gt;} &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
      &lt;/div&gt;
      where YOUR_CONNECTION_STRING is, uh, your connection string.  Use a snippet like that in your Application_Start.&lt;br /&gt;
      If you happen to work with me, I've made this into a library function, so we can use it across projects:
      &lt;div class="Code"&gt;
         Utils.ConfigLog4netConnection();
      &lt;/div&gt;
   
   &lt;h2&gt;Creating your loggers with less typing&lt;/h2&gt;
   &lt;p&gt;
      Typing:
      &lt;/p&gt;&lt;div&gt;         
         protected static readonly ILog log = LogManager.GetLogger(typeof(&lt;u&gt;CLASS&lt;/u&gt;));
      &lt;/div&gt;
      is a bother because typing the name of the class is annoying.  &lt;a href="http://dotnetworkaholics.com/"&gt;Paul Lockwood&lt;/a&gt; 
      shared this shortcut after making a presentation on log4net in Atlanta.  Copy/Paste is usually the devil, but in this case, I think it's ok.  
      &lt;div class="Code"&gt;
         protected static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
      &lt;/div&gt;
      Sayeth Mr. Lockwood:
      &lt;blockquote&gt;
      
It saves having to find the classname every time you declare log.
Reflection will mean slight performance degradation when the static
initializer executes but in most apps this is insignificant.

      &lt;/blockquote&gt;
      I think the initialization time is extra insignificant with web apps, so that sounds like a plan to me.  Thanks to everyone who read and commented
      on that walkthrough.
   &lt;img src ="http://blogs.acceleration.net/ryan/aggbug/1174.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>
      It's been awhile since I wrote the <a href="http://blogs.acceleration.net/ryan/articles/379.aspx">walkthrough</a>, and I've come across
      a few more problems and solutions.  Most of the walkthrough still applies, but here are two tips to make it even easier.
   </p>
   <h2>Connection string management</h2>
   <p>
      The connection string for ADONetAppenders is set in the web.config.  You usually
      also have a connection string specified elsewhere for the rest of your application to use, 
      and having to specify it again is a little nasty, but not too bad.  The real problem is when
      you have a dev/test/live database setup.  You probably already have some system for swapping your main connection string.
      The solution is to set the log4net connection string on initialization, and ignore the one specified in web.config.<br />
      Instead of just calling:
      </p><div>
      log4net.Config.DOMConfigurator.Configure();
      </div>
      to initalize log4net, call this:
      <div class="Code">
         <table class="dp-c" border="0" cellpadding="0" cellspacing="0" id="Table1"><tbody><tr></tr><tr><td class="line"><span></span><span class="keyword">try</span><span>{ </span></td></tr><tr><td class="line">   <span class="comment">//configure the damn thing.</span><span> </span></td></tr><tr><td class="line">   log4net.Config.DOMConfigurator.Configure(); </td></tr><tr><td class="line"> </td></tr><tr><td class="line">   log4net.Repository.Hierarchy.Hierarchy h = LogManager.GetLoggerRepository() <span class="keyword">as</span><span> log4net.Repository.Hierarchy.Hierarchy; </span></td></tr><tr><td class="line">   <span class="comment">//get the ADO appender</span><span> </span></td></tr><tr><td class="line">   log4net.Appender.ADONetAppender ado = h.Root.GetAppender(<span class="string">"ADONetAppender"</span><span>) </span><span class="keyword">as</span><span> log4net.Appender.ADONetAppender; </span></td></tr><tr><td class="line">   ado.ConnectionString = YOUR_CONNECTION_STRING; </td></tr><tr><td class="line">   ado.ActivateOptions(); </td></tr><tr><td class="line">   <span class="keyword">return</span><span> conn; </span></td></tr><tr><td class="line">}<span class="keyword">catch</span><span>(NullReferenceException nfe) { </span></td></tr><tr><td class="line">   <span class="keyword">throw</span><span> </span><span class="keyword">new</span><span> NullReferenceException(</span><span class="string">"log4net configuration could not be completed.  \nDo you have your app.config set up properly?"</span><span>, nfe); </span></td></tr><tr><td class="line">} </td></tr></tbody></table>
      </div>
      where YOUR_CONNECTION_STRING is, uh, your connection string.  Use a snippet like that in your Application_Start.<br />
      If you happen to work with me, I've made this into a library function, so we can use it across projects:
      <div class="Code">
         Utils.ConfigLog4netConnection();
      </div>
   
   <h2>Creating your loggers with less typing</h2>
   <p>
      Typing:
      </p><div>         
         protected static readonly ILog log = LogManager.GetLogger(typeof(<u>CLASS</u>));
      </div>
      is a bother because typing the name of the class is annoying.  <a href="http://dotnetworkaholics.com/">Paul Lockwood</a> 
      shared this shortcut after making a presentation on log4net in Atlanta.  Copy/Paste is usually the devil, but in this case, I think it's ok.  
      <div class="Code">
         protected static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
      </div>
      Sayeth Mr. Lockwood:
      <blockquote>
      
It saves having to find the classname every time you declare log.
Reflection will mean slight performance degradation when the static
initializer executes but in most apps this is insignificant.

      </blockquote>
      I think the initialization time is extra insignificant with web apps, so that sounds like a plan to me.  Thanks to everyone who read and commented
      on that walkthrough.
   <img src ="http://blogs.acceleration.net/ryan/aggbug/1174.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Ryan</dc:creator><title>Code Generation with Python, Cog, and Nant</title><link>http://blogs.acceleration.net/ryan/archive/2005/01/25/578.aspx</link><pubDate>Tue, 25 Jan 2005 16:14:00 GMT</pubDate><guid>http://blogs.acceleration.net/ryan/archive/2005/01/25/578.aspx</guid><description>I posted an article about how I do &lt;a href="http://blogs.acceleration.net/ryan/articles/577.aspx"&gt;Code Generation with Python, Cog, and Nant&lt;/a&gt;.  
&lt;br /&gt;
Check it out.&lt;img src ="http://blogs.acceleration.net/ryan/aggbug/578.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">I posted an article about how I do <a href="http://blogs.acceleration.net/ryan/articles/577.aspx">Code Generation with Python, Cog, and Nant</a>.  
<br />
Check it out.<img src ="http://blogs.acceleration.net/ryan/aggbug/578.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Ryan</dc:creator><title>IMEX=1, of course!</title><link>http://blogs.acceleration.net/ryan/archive/2005/01/11/477.aspx</link><pubDate>Tue, 11 Jan 2005 17:28:00 GMT</pubDate><guid>http://blogs.acceleration.net/ryan/archive/2005/01/11/477.aspx</guid><description>So, I've been writing a little app to combine some Excel spreadsheets.  These sheets all have header rows, so I cand open them up with an OleDbConnection, do a "SELECT * FROM [Sheet1$]"
   and go along my merry way.  The problem is, two of the columns I need to work with just aren't there.  They're on the excel sheet just
   fine, but my OleDbDataReader finds nothing in those columns on any row.  Looking at the sheet, I see that in those columns, there isn't any data for about 12 rows.
   So, I put in zeros at the top of those columns, and then it works fine.  &lt;br /&gt;&lt;br /&gt;
   Is the OleDbConnection really making assumptions about the dataset based on the first row?  After much googling and little success, I try to find a definition of the 
   connectionstring, hoping there's some attribute like "rows to scan for schema" I can set, to tell it to actually read my data.  &lt;a title="Nathan's blog" href="http://blogs.acceleration.net/birdman/"&gt;Nathan&lt;/a&gt; points me to an excellent
   resource, &lt;a href="http://www.connectionstrings.com/"&gt;Connectionstrings.com&lt;/a&gt;, and they kindly let me know that I can specify &lt;code&gt;HDR=Yes;&lt;/code&gt; to indicate that I have a 
   header row in my sheets, and &lt;code&gt;IMEX=1;&lt;/code&gt; which, according to  &lt;a href="http://www.connectionstrings.com/"&gt;Connectionstrings.com&lt;/a&gt;:
   &lt;blockquote&gt;
      tells the driver to always read "intermixed" data columns as text
   &lt;/blockquote&gt;
   Apparently, the two columns in question were, in fact "intermixed" data columns, and once I set that in my connectionstring, all worked fine.&lt;br /&gt;&lt;br /&gt;
   The mixed use of "1" and "Yes" aside, why the hell would your database driver just silently ignore data?  I mean, if "intermixed" data columns is an error
   condition, then have the balls to throw a exception, warning, event log entry, anything.  Don't just not work and expect me to magically know where the problem is.
   I almost reimplemented the whole damn thing using Excel objects and the Office API, and that would've taken me another couple of days.  A pox on the Excel team!&lt;br /&gt;
   &lt;br /&gt;Well, I guess not a pox, because at some point some manager sat them in a room and said "Ok, now lets let people query this using SQL!", which was probably
   punishment enough.&lt;img src ="http://blogs.acceleration.net/ryan/aggbug/477.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">So, I've been writing a little app to combine some Excel spreadsheets.  These sheets all have header rows, so I cand open them up with an OleDbConnection, do a "SELECT * FROM [Sheet1$]"
   and go along my merry way.  The problem is, two of the columns I need to work with just aren't there.  They're on the excel sheet just
   fine, but my OleDbDataReader finds nothing in those columns on any row.  Looking at the sheet, I see that in those columns, there isn't any data for about 12 rows.
   So, I put in zeros at the top of those columns, and then it works fine.  <br /><br />
   Is the OleDbConnection really making assumptions about the dataset based on the first row?  After much googling and little success, I try to find a definition of the 
   connectionstring, hoping there's some attribute like "rows to scan for schema" I can set, to tell it to actually read my data.  <a title="Nathan's blog" href="http://blogs.acceleration.net/birdman/">Nathan</a> points me to an excellent
   resource, <a href="http://www.connectionstrings.com/">Connectionstrings.com</a>, and they kindly let me know that I can specify <code>HDR=Yes;</code> to indicate that I have a 
   header row in my sheets, and <code>IMEX=1;</code> which, according to  <a href="http://www.connectionstrings.com/">Connectionstrings.com</a>:
   <blockquote>
      tells the driver to always read "intermixed" data columns as text
   </blockquote>
   Apparently, the two columns in question were, in fact "intermixed" data columns, and once I set that in my connectionstring, all worked fine.<br /><br />
   The mixed use of "1" and "Yes" aside, why the hell would your database driver just silently ignore data?  I mean, if "intermixed" data columns is an error
   condition, then have the balls to throw a exception, warning, event log entry, anything.  Don't just not work and expect me to magically know where the problem is.
   I almost reimplemented the whole damn thing using Excel objects and the Office API, and that would've taken me another couple of days.  A pox on the Excel team!<br />
   <br />Well, I guess not a pox, because at some point some manager sat them in a room and said "Ok, now lets let people query this using SQL!", which was probably
   punishment enough.<img src ="http://blogs.acceleration.net/ryan/aggbug/477.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Ryan</dc:creator><title>NAnt, NUnit, NDoc, Oh my!</title><link>http://blogs.acceleration.net/ryan/archive/2004/12/07/402.aspx</link><pubDate>Tue, 07 Dec 2004 20:42:00 GMT</pubDate><guid>http://blogs.acceleration.net/ryan/archive/2004/12/07/402.aspx</guid><description>   So, my confidence in open source was riding high after &lt;a href="http://blogs.acceleration.net/ryan/articles/379.aspx"&gt;my experience&lt;/a&gt; 
   with &lt;a href="http://logging.apache.org/log4net/"&gt;log4net&lt;/a&gt;, so I decided to try some more.&lt;br /&gt;
   &lt;br /&gt;
   &lt;u&gt;Summary of tools&lt;/u&gt;&lt;br /&gt;
   If I can find the time, I'll put together more in-depth articles for these, but for now, just an overview:
   &lt;ol&gt;
      &lt;li&gt;&lt;a href="http://ndoc.sourceforge.net/"&gt;NDoc&lt;/a&gt; is a tool for generating HTML or CHM documentation based on the XML comments in your code.  It's very similar to Javadocs, and can even
      generate HTML in that style.  I've been using this one in a few places for a little while.  Their GUI is very easy to use, and their command-line utility has good documentation.&lt;/li&gt;
      
      &lt;li&gt;&lt;a href="http://www.nunit.org/index.html"&gt;NUnit&lt;/a&gt; is a unit testing framework written in C#.  The idea is you write a lot of small, atomic tests, and then at
      any point in development you can make a huge change and run your tests to find out where you screwed up.  NUnit has the concept of &lt;a href="http://www.nunit.org/testFixture.html"&gt;TestFixture&lt;/a&gt;s, which is an attribute 
      you add to any class you want to run test in.  You slap that attribute at the top, then make your tests, giving them the &lt;a href="http://www.nunit.org/test.html"&gt;Test&lt;/a&gt; attribute, and away you go, it uses reflection
      to figure out the rest.
      &lt;/li&gt;
      
      &lt;li&gt;&lt;a href="http://nant.sourceforge.net/"&gt;NAnt&lt;/a&gt; is a build system that is a replacement for makefiles.  It lets you specify targets and such like makefiles.  This is by far the most complicated of the 
      three, but it still only took a half day to get it to do what I wanted.&lt;/li&gt;
   &lt;/ol&gt;
   &lt;u&gt;How I'm using them&lt;/u&gt;&lt;br /&gt;
   We're working on a large internal project, so I'm using it as an excuse to spend time getting a decent build system going.  
   So far building has been via Visual Studio (not bad) and testing has been manual through the browser (probably bad).  The project is divided into several different assemblies, with one of 
   them being for testing.  &lt;br /&gt;
   &lt;br /&gt;
   &lt;u&gt;NUnit&lt;/u&gt;&lt;br /&gt;
   After futzing around getting my bearings for a few days, I established my unit test pattern:&lt;br /&gt;
   Make a parallel namespaces in the Tests project, and put tests for actual class &lt;code&gt;X&lt;/code&gt; in test 
   class &lt;code&gt;XTest&lt;/code&gt;, and have &lt;code&gt;XTest&lt;/code&gt; inherit from &lt;code&gt;X&lt;/code&gt;.  Each &lt;code&gt;XTest&lt;/code&gt; is marked as a &lt;a href="http://www.nunit.org/testFixture.html"&gt;TestFixture&lt;/a&gt;.
   Initially I had a problem with connectionstrings, but that went away when I ran tests through NAnt.  It enabled me to specify a .config 
   file to use with the test.  I'm guessing there's a way to do that with the NUnit GUI, but once I got NAnt going, it wasn't an issue.&lt;br /&gt;
   &lt;br /&gt;
   I had a big problem with side-effects of my tests.  I'm testing database code, so that naturally affects the database.  I've read a little about &lt;a href="http://www.mockobjects.com/Faq.html#head-76f6eae2365ef12ff3dcb1bbfef7ab0a4dc77c92"&gt;Mock Objects&lt;/a&gt;, but part of what I want to 
   test is the stored procedures called from my generated objects.  I tried to make all
   my tests clean up after themselves in object-space, but that proved extremely ugly, forcing me to add superfluous member variables and output parameters so I could get a reference
   to everything I had added.  It turned the API really nasty.&lt;br /&gt;
   I then discovered the &lt;a href="http://www.nunit.org/setupTeardown.html"&gt;TestFixtureSetUp&lt;/a&gt; and &lt;a href="http://www.nunit.org/setupTeardown.html"&gt;TestFixtureTearDown&lt;/a&gt; attributes, which allowed me to specify code to be run at the beginning and end of 
   a &lt;a href="http://www.nunit.org/testFixture.html"&gt;TestFixture&lt;/a&gt;.  At that point I had only one &lt;a href="http://www.nunit.org/testFixture.html"&gt;TestFixture&lt;/a&gt;, so it was perfect.  I got it backing up the DB everytime, learning more about the T-SQL RESTORE command than I felt was appropriate.
   When I started adding more test fixtures, it became a problem.  There doesn't seem to be a place to specify a global SetUp or TearDown.  NUnit does have the idea of test &lt;a href="http://www.nunit.org/suite.html"&gt;Suite&lt;/a&gt;s, where you explictly
   instantiate every &lt;a href="http://www.nunit.org/testFixture.html"&gt;TestFixture&lt;/a&gt; and run each test, but their page on it seems discouraging of that, and I don't want to do even more extra work.  This is where I decided to
   employ NAnt.&lt;br /&gt;
   &lt;br /&gt;
   &lt;u&gt;NAnt&lt;/u&gt;&lt;br /&gt;
   NAnt's system of build targets let me specify things nicely.  I set up a NAnt task to build the project, another to run the tests, and then started in on
   working the database into it.  After much discussion with other programmers, who for the most part, didn't care either way, I decided on a solution suggested
   by my friend Chris Black.  He suggested to make a copy of the real DB, and run the tests on that.  If the tests screw up, it doesn't matter.  I liked that
   over making a backup beforehand and restoring afterwards, which might cause some concurrency issues.  So I wrote a program to restore the DB as DB_UnitTests, and set up
   the NAnt tasks to do so before running the tests.  Eventually I made it better, adding another task to get a new backup of the real DB.&lt;br /&gt;&lt;br /&gt;
   I end up with a command prompt up on monitor number two, constantly running things like &lt;code&gt;nant test&lt;/code&gt;, &lt;code&gt;nant clean-test&lt;/code&gt;, and &lt;code&gt;nant doc&lt;/code&gt;.&lt;br /&gt;
   &lt;br /&gt;
   &lt;u&gt;NDoc&lt;/u&gt;&lt;br /&gt;
   I expected this to be the smoothest part to get working, but it actually took some effort.  NAnt has a built-in task to run &lt;a href="http://ndoc.sourceforge.net/"&gt;NDoc&lt;/a&gt;, allowing you to specify the assemblies
   to document there in your NAnt build file, but I couldn't get the damn thing to work.  It would generate 4500 HTML files, but there'd be no index.html, and Windows Explorer
   really does not like to have that many files in a folder.  I wound up configuring a &lt;a href="http://ndoc.sourceforge.net/"&gt;NDoc&lt;/a&gt; project using the &lt;a href="http://ndoc.sourceforge.net/"&gt;NDoc&lt;/a&gt; GUI, and then calling the command-line version of &lt;a href="http://ndoc.sourceforge.net/"&gt;NDoc&lt;/a&gt; from
   NAnt.  It takes about 10 minutes to generate the documentation, so its certainly not something done on every build.  And thats 10 minutes of 100% CPU usage.  I'm guessing this is 
   the type of thing I'd do when I'm on my way out the door.  I also added something in there to make a windows help file
   (CHM), and have that being copied into a different folder using NAnt, so I can open that without needing to choke my computer with a few thousand files in a folder.
   &lt;br /&gt;&lt;br /&gt;
   Check out these tools, I think they are going to be a good long-term time investment.&lt;img src ="http://blogs.acceleration.net/ryan/aggbug/402.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">   So, my confidence in open source was riding high after <a href="http://blogs.acceleration.net/ryan/articles/379.aspx">my experience</a> 
   with <a href="http://logging.apache.org/log4net/">log4net</a>, so I decided to try some more.<br />
   <br />
   <u>Summary of tools</u><br />
   If I can find the time, I'll put together more in-depth articles for these, but for now, just an overview:
   <ol>
      <li><a href="http://ndoc.sourceforge.net/">NDoc</a> is a tool for generating HTML or CHM documentation based on the XML comments in your code.  It's very similar to Javadocs, and can even
      generate HTML in that style.  I've been using this one in a few places for a little while.  Their GUI is very easy to use, and their command-line utility has good documentation.</li>
      
      <li><a href="http://www.nunit.org/index.html">NUnit</a> is a unit testing framework written in C#.  The idea is you write a lot of small, atomic tests, and then at
      any point in development you can make a huge change and run your tests to find out where you screwed up.  NUnit has the concept of <a href="http://www.nunit.org/testFixture.html">TestFixture</a>s, which is an attribute 
      you add to any class you want to run test in.  You slap that attribute at the top, then make your tests, giving them the <a href="http://www.nunit.org/test.html">Test</a> attribute, and away you go, it uses reflection
      to figure out the rest.
      </li>
      
      <li><a href="http://nant.sourceforge.net/">NAnt</a> is a build system that is a replacement for makefiles.  It lets you specify targets and such like makefiles.  This is by far the most complicated of the 
      three, but it still only took a half day to get it to do what I wanted.</li>
   </ol>
   <u>How I'm using them</u><br />
   We're working on a large internal project, so I'm using it as an excuse to spend time getting a decent build system going.  
   So far building has been via Visual Studio (not bad) and testing has been manual through the browser (probably bad).  The project is divided into several different assemblies, with one of 
   them being for testing.  <br />
   <br />
   <u>NUnit</u><br />
   After futzing around getting my bearings for a few days, I established my unit test pattern:<br />
   Make a parallel namespaces in the Tests project, and put tests for actual class <code>X</code> in test 
   class <code>XTest</code>, and have <code>XTest</code> inherit from <code>X</code>.  Each <code>XTest</code> is marked as a <a href="http://www.nunit.org/testFixture.html">TestFixture</a>.
   Initially I had a problem with connectionstrings, but that went away when I ran tests through NAnt.  It enabled me to specify a .config 
   file to use with the test.  I'm guessing there's a way to do that with the NUnit GUI, but once I got NAnt going, it wasn't an issue.<br />
   <br />
   I had a big problem with side-effects of my tests.  I'm testing database code, so that naturally affects the database.  I've read a little about <a href="http://www.mockobjects.com/Faq.html#head-76f6eae2365ef12ff3dcb1bbfef7ab0a4dc77c92">Mock Objects</a>, but part of what I want to 
   test is the stored procedures called from my generated objects.  I tried to make all
   my tests clean up after themselves in object-space, but that proved extremely ugly, forcing me to add superfluous member variables and output parameters so I could get a reference
   to everything I had added.  It turned the API really nasty.<br />
   I then discovered the <a href="http://www.nunit.org/setupTeardown.html">TestFixtureSetUp</a> and <a href="http://www.nunit.org/setupTeardown.html">TestFixtureTearDown</a> attributes, which allowed me to specify code to be run at the beginning and end of 
   a <a href="http://www.nunit.org/testFixture.html">TestFixture</a>.  At that point I had only one <a href="http://www.nunit.org/testFixture.html">TestFixture</a>, so it was perfect.  I got it backing up the DB everytime, learning more about the T-SQL RESTORE command than I felt was appropriate.
   When I started adding more test fixtures, it became a problem.  There doesn't seem to be a place to specify a global SetUp or TearDown.  NUnit does have the idea of test <a href="http://www.nunit.org/suite.html">Suite</a>s, where you explictly
   instantiate every <a href="http://www.nunit.org/testFixture.html">TestFixture</a> and run each test, but their page on it seems discouraging of that, and I don't want to do even more extra work.  This is where I decided to
   employ NAnt.<br />
   <br />
   <u>NAnt</u><br />
   NAnt's system of build targets let me specify things nicely.  I set up a NAnt task to build the project, another to run the tests, and then started in on
   working the database into it.  After much discussion with other programmers, who for the most part, didn't care either way, I decided on a solution suggested
   by my friend Chris Black.  He suggested to make a copy of the real DB, and run the tests on that.  If the tests screw up, it doesn't matter.  I liked that
   over making a backup beforehand and restoring afterwards, which might cause some concurrency issues.  So I wrote a program to restore the DB as DB_UnitTests, and set up
   the NAnt tasks to do so before running the tests.  Eventually I made it better, adding another task to get a new backup of the real DB.<br /><br />
   I end up with a command prompt up on monitor number two, constantly running things like <code>nant test</code>, <code>nant clean-test</code>, and <code>nant doc</code>.<br />
   <br />
   <u>NDoc</u><br />
   I expected this to be the smoothest part to get working, but it actually took some effort.  NAnt has a built-in task to run <a href="http://ndoc.sourceforge.net/">NDoc</a>, allowing you to specify the assemblies
   to document there in your NAnt build file, but I couldn't get the damn thing to work.  It would generate 4500 HTML files, but there'd be no index.html, and Windows Explorer
   really does not like to have that many files in a folder.  I wound up configuring a <a href="http://ndoc.sourceforge.net/">NDoc</a> project using the <a href="http://ndoc.sourceforge.net/">NDoc</a> GUI, and then calling the command-line version of <a href="http://ndoc.sourceforge.net/">NDoc</a> from
   NAnt.  It takes about 10 minutes to generate the documentation, so its certainly not something done on every build.  And thats 10 minutes of 100% CPU usage.  I'm guessing this is 
   the type of thing I'd do when I'm on my way out the door.  I also added something in there to make a windows help file
   (CHM), and have that being copied into a different folder using NAnt, so I can open that without needing to choke my computer with a few thousand files in a folder.
   <br /><br />
   Check out these tools, I think they are going to be a good long-term time investment.<img src ="http://blogs.acceleration.net/ryan/aggbug/402.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Ryan</dc:creator><title>log4net walkthrough</title><link>http://blogs.acceleration.net/ryan/archive/2004/11/10/380.aspx</link><pubDate>Wed, 10 Nov 2004 16:53:00 GMT</pubDate><guid>http://blogs.acceleration.net/ryan/archive/2004/11/10/380.aspx</guid><description>After being asked for the third time, I put together a walkthrough for adding &lt;a href="http://logging.apache.org/log4net/"&gt;&lt;code&gt;log4net&lt;/code&gt;&lt;/a&gt; to a project.  log4net is a really nice open-source logging framework.&lt;br /&gt;
&lt;br /&gt;
See the full article: &lt;a href="http://blogs.acceleration.net/ryan/articles/379.aspx"&gt;log4net walkthrough&lt;/a&gt;&lt;img src ="http://blogs.acceleration.net/ryan/aggbug/380.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">After being asked for the third time, I put together a walkthrough for adding <a href="http://logging.apache.org/log4net/"><code>log4net</code></a> to a project.  log4net is a really nice open-source logging framework.<br />
<br />
See the full article: <a href="http://blogs.acceleration.net/ryan/articles/379.aspx">log4net walkthrough</a><img src ="http://blogs.acceleration.net/ryan/aggbug/380.aspx" width = "1" height = "1" /></body></item></channel></rss>