May 2009 - Posts

Ajax Survey

From BradA: Simone Chiaretta is doing another Ajax survey to see how things have changed since his last survey a couple of years ago.  I just filled it out (you should too!).  The survey can be found here.

Oh, and if the suspense is killing you, I'll give you my answers:

  1. I'm using AJAX in a production application.
  2. It's part of a MonoRail application.
  3. I'm using the Prototype on the client.
Technorati Tags: ,,
Posted by PSteele | with no comments
Filed under: ,

Fabulous Adventures In Coding

If you don't read Eric Lippert's Fabulous Adventures In Coding, you're really missing out on some great stuff.

I've been reading his blog for years and it's always an entertaining read.  I caught a presentation Eric gave at the MVP Summit in 2008 and also had an opportunity to speak with him one-on-one that year as he attended the C# dinner at Maggianos.  He's a guy that has so much knowledge, you wonder why his head doesn't explode!  :)

I decided to write about Eric's blog today because I only take time to read his posts if I'm sure I have time to let them soak in.  Some blogs I subscribe to just get a quick glance-over looking for good material.  But Eric's is always good so I've got a number of his posts from the past few weeks that I just caught up on this morning.  A few gems:

"foreach" vs. "ForEach": I always wondered why .NET didn't provide a ForEach extension method.  Now I know.

In Foof We Trust: A Dialogue: A great Q&A style post where Eric answers a question on why implementing an obviously cool and useful feature can quickly become very complicated.

Enjoy!

Technorati Tags: ,,
Posted by PSteele | 2 comment(s)
Filed under: ,

XmlSerializer ignores Culture

I'm working with an automotive client that has a couple of data formats for some of their files.  One is a simple CSV format and the other is XML using .NET's XML Serializer (nothing fancy).  The CSV format is handy as it's easy for the engineers to quickly load it into Excel and view in a columnar format.  The XML format was implemented as a much more "full featured" version of the data and contains additional metadata to describe the data.  All of the maintenance of these files is very easy as we have a library for dealing with them.

One of the issues that was found early on in the development of the library was that, being a global automotive company, the CSV wasn't always "comma separated".  Most european countries use the period (".") as a thousands separator and comma (",") as a decimal separator (i.e. three thousand dollars in this format would be "3.000,00").  A lot of work was put into trying to infer the culture of the machine that created the file so it could be read by any other culture.  There were bugs from time to time and we found a few anomalies that made things more difficult.  But it worked okay for the most part.

Recently, a decision was made (by people much higher than me) that going forward, the file formats (both CSV and XML) will always be in the English/US format (en-US).  This made exchange of these files easier all around as our library wasn't the only application that read these files and some other apps were having problems with the multi-culture issue.  Standardizing on the en-US format made things a lot simpler in the CSV read/write code as well as other applications.

In the XML code, I wanted to write some unit tests to make sure it also would always read/write in en-US format.  To my surprise, no matter what I set my Thread's CurrentCulture to, the XML always came out in en-US format.  I did some digging and found a thread about this on the ASP.NET forums.  One particular post cleared things up for me.  Martin Honnen (XML MVP) stated:

Well XML serialization uses a standardized number and date/dateTime format, the standard is the W3C schema datatype specification http://www.w3.org/TR/xmlschema-2/.

So don't expect XmlSerializer to pay attention to the thread's CultureInfo, it intentionally uses a standardized format to ensure you can serialize/deserialize independent of the culture/locale.

Sweet!  Culture isn't an issue with the XML Serializer!  Thanks Martin.

Technorati Tags: ,,
Posted by PSteele | 1 comment(s)
Filed under:

OutputDebugStringAppender in a web app?

I spent a couple of hours yesterday trying to get log4net to log to an OutputDebugStringAppender with no success.  At first, I thought I had a configuration error in log4net so I added a file appender and that works fine.  It's a Monorail application that uses ActiveRecord for database access.  There's a couple of spots where I wanted to check out the SQL being generated by ActiveRecord (NHibernate).  I did all my set up for log4net and even got it logging to a FileAppender.  But I wanted to log the SQL to an OutputDebugStringAppender.

Here's my logging set up:

   1: <log4net>
   2:     <!-- Define some output appenders -->
   3:     <appender name="logfile" type="log4net.Appender.FileAppender, log4net">
   4:         <file value="log-file.txt" />
   5:         <appendToFile value="true" />
   6:         <layout type="log4net.Layout.PatternLayout">
   7:             <conversionPattern value="%d [%t] %-5p %c - %m%n"/>
   8:         </layout>
   9:     </appender>
  10:     <appender name="ods" type="log4net.Appender.OutputDebugStringAppender, log4net">
  11:         <layout type="log4net.Layout.PatternLayout,log4net">
  12:             <conversionPattern value="%d [%t] %-5p %c - %m%n"/>
  13:         </layout>
  14:     </appender>
  15:     <logger name="NHibernate.SQL">
  16:         <level value="ALL" />
  17:         <appender-ref ref="logfile" />
  18:         <appender-ref ref="ods" />
  19:     </logger>
  20:     <root>
  21:         <!-- priority value can be set to ALL|INFO|WARN|ERROR -->
  22:         <priority value="ALL" />
  23:         <appender-ref ref="ods" />
  24:     </root>
  25: </log4net>

The log-file.txt gets all the logging I want, but I really just wanted to be able to view these statements in DebugView (gives me a bit more control in clearing out past queries, setting filters/highlight colors, etc…)

I'm positive I had something like this working before but I get NOTHING in DebugView.  Anyone have any ideas as to what I'm doing wrong?  Is there a permission issue that makes this not possible?

Posted by PSteele | 2 comment(s)

New CodeMash Website

As you've probably heard (via Twitter), there's a new look to the CodeMash website.  SRT Solutions and inner circle media have been working on the website for a while now getting things organized.  Much of the praise for the new look goes to inner circle media – Catherine Hayes and Alaine Karoleff have put a lot of thought and design into the new site and it shows!

As Brian pointed out in his tweet, this is just the beginning – there's more to come as CodeMash get closer and closer.  And check out the news – CodeMash 2011 already has a date!  Start your planning now!  I'm thinking that an 18-month notice is more than enough time for your employer to give you the time off.

Technorati Tags: ,
Posted by PSteele | with no comments
Filed under: ,
More Posts