Thursday, December 15, 2005

Tonight, for those that can make it, Kathleen Dollard is presenting on WinForms Databinding with the Utah County .NET User's Group.  It should be a fun time.  For those that might not be aware, they meet down on the UVSC campus in room CS512 at 6:00 PM.

If I'm not mistaken this month's meeting marks the 1 year anniversary of the UCNUG, which is pretty exciting!

Hehe, I looked at Kathleen's blog (which, btw, doesn't have any activity since April 2005) and was amazed at her stats: 57 posts, 21148 comments!  Holy cow, must be incredibly insightful.  But then I saw that 99% are spam...which is unfortunate.

Thursday, December 15, 2005 9:27:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback

This is pretty cool - I downloaded it, installed it, played it, was impressed, and promptly died.  I gotta get used to the controls but they guys that worked on this (Dobermann, Chainsaw, et al) did a fantastic job...looks like lots of fun and it's very well done.

If you're a fan of the original XBox Halo (by Bungie), you gotta check out this Halo side scroller called HaloZero.

Thursday, December 15, 2005 8:16:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, December 13, 2005

Spider-man has been a favorite of mine for a long time, so I kinda like the results.

You are Spider-Man
Spider-Man 75%
The Flash 75%
Green Lantern 70%
Robin 67%
Superman 65%
Hulk 60%
Iron Man 60%
Catwoman 50%
Supergirl 48%
Batman 45%
Wonder Woman 38%
You are intelligent, witty,
a bit geeky and have great
power and responsibility.
Click here to take the "Which Superhero are you?" quiz...
Tuesday, December 13, 2005 4:38:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback

Recently I've had the need to serialize an object using the XmlSerializer.  By default, when you serialize an object it will automatically add the default xmlns:xsd="..." and xmlns:xsi="..." namespaces to the root element of the xml document.  In my particular case this was not desirable, but there wasn't any obvious way to remove them.  As it turns out, there really is, but it's semi-obscure.

As it turns out, I did this a few years ago back in my .NET 1.0 days, but it had since evaporated from my memory, but I found a nice little blog post that jogged my memory.  All you have to do is use an XmlSerializerNamespaces object with an empty namespace.  The .NET framework will inspect this object for any namespaces.  A null reference or zero entries will cause the serializer to include the defaults.  Any namespaces (even empty ones) override the default behavior, thereby not including the default.  A simple example might resemble the following:

internal string SerializeCustomer(Customer cust) {
   using ( StringWriter writer = new StringWriter(CultureInfo.InvariantCulture) ) {
      XmlSerializer ser = new XmlSerializer(typeof(Customer));
      // remove the xsd and xsi namespaces from the serialization output by
      // appending a blank namespace

      XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
      xsn.Add(string.Empty, string.Empty);
      // serialize the object and extract the result from the writer
      ser.Serialize(writer, cust, xsn);
      return writer.ToString();
   }
}

Tuesday, December 13, 2005 4:33:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [5]  |  Trackback
 Wednesday, December 07, 2005

This is pretty exciting.  Today Phil and I (collectively DevUtah) announced the second of many Geek Dinners to come.  The first one was a smashing success and we hope this one can be a great event as well - hopefully with a little more coordination.  Put it on your calendar and register on the RSVP list for December 20th, 2005 at 6:00 PM.  The location has yet to be determined but once we have that secured we'll post that as well.

Invite your friends and colleagues.  I know of several people that couldn't make the last one for one reason or another; hopefully we'll have all the gang out with many new faces as well.  Let's build the community!

Wednesday, December 07, 2005 6:56:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [2]  |  Trackback

Tonight I'm very excited to announce that Ted Neward is going to grace us of the Utah .NET User Group with his presence in an INETA sponsored event.  He's going to be addressing the topic of Indigo (now formally known as the Windows Communication Foundation Services).  The meeting is open to all and all are welcome.

As usual we meet at 6:00 PM and Neumont University (10701 W. River Front Parkway, South Jordan, Utah) is kind enough to provide us with space to meet.  If you are planning on coming, please RSVP.  We've received a VERY limited number of RSVP's (which has me a little concerned).  We want to make sure that we don't over- or under-purchase refreshments.

Anyway, we'll see you there...it should be a great time!

Wednesday, December 07, 2005 6:49:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, December 01, 2005

Today I ran into an issue that I had not encountered (at least not in this manifestation) while compiling an assembly so I thought I'd share the solution.  The error was simply:

Cryptographic failure while signing assembly '....' Access is denied.

As it turns out I had just rebuilt my laptop from the ground up.  I don't run my computer in an administrator capacity and my process of installing was, this time, a little different that how I usually rebuild my machines; I made sure I wasn't an administrator immediately upon having installed Windows.  However, rather than temporarily promoting myself to Admin via the MakeMeAdmin utilities to install my development environment, I installed VS.NET while logged in as the Administrator user directly.  The byproduct of this was that my non-administrator user account was never granted permissions to a required directory for signing assemblies.

To remedy the problem I simply opened an Explorer window as an administrator and altered the ACLs on the necessary directory.  I granted my user Full Control on %ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\RSA\MachineKeys.  Simply restart Visual Studio (if it was open) and you should be off and rolling.

Thursday, December 01, 2005 3:57:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [26]  |  Trackback

Today I had the pleasure of attending the VS.NET 2005 / SQL Server 2005 Launch event here in Salt Lake City, Utah.  The event was held at Jordan Commons and it's a good thing too.  We had one of the theatres completely packed.  About 700 people attended the afternoon session on VS.NET and almost that many in the morning for the SQL Server event.

It was a lot of fun to once again make contact with so many friends and associates and partake in the geekdom.  The opportunity was mine to work on the event staff, as I am inclined to do for these events, participating in the various community events around the valley and neighboring cities..  It was great to greet people and then catch periodic glimpses of the sessions.  What a follow-up to the Geek Dinner that we had last night.

There are days where I love what I do.

Thursday, December 01, 2005 9:09:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Wednesday, November 30, 2005

We had an awesome Geek Dinner tonight organized by DevUtah and sponsored by DevUtah and ProvoLabs.  We had about 65 people show up for a fantastic dinner at Los Hermanos.  After a few logistical issues we all got settled in and had a great presentation by Dr. Phil Windley on microformats.  It was a lot of fun.  We then each had the opportunity to share information about the various user groups around the valleys (.NET, PHP, Linux, Unix, Ruby, etc).

When Phil and I started DevUtah we were hoping for some community enthusiasm and I think we got it...what fun!  I just wish that more of the .NET group had shown up - virtually no one from the .NET User Group was there which was very disappointing.  The vast majority of attendees were BYU students and open source enthusiasts (but there's nothing wrong with that).

Our plan is to be able to put on these Geek Dinners once a month, and I hope this enthusiasm continues.

Wednesday, November 30, 2005 4:03:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [3]  |  Trackback

Today, in less than 6 hrs we're having a Geek Dinner at Los Hermanos Restaurant in Lindon, Utah.  The event is open to everyone and all are invited.  If you'd like to come, please RSVP on the wiki.  Thus far 57 people have registered, which is awesome!

Don't forget, there will be giveaways, a great speaker, Dr. Phil Windley from BYU, great food (everyone buys their own plate), wireless internet, etc.  The even will be filmed and podcasted as well.

So sign up and be there tonight @ 6:00 PM.

Wednesday, November 30, 2005 5:42:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, November 29, 2005

About a month ago I posted an article on how I like to use SqlDataReaders.  In said article I discussed how, rather than actually retrieving a data reader from my command object and walking the results, I like to walk the data reader in a callback method.  I propose that this strategy helps constrain how data readers are used and better manages their lifetimes.

I want to take it a step further now and talk about some additional enhancements that can be made to enhance the experience of using data readers all the while leveraging some cool .NET 2.0 functionality.  Last month's post was intended to be informative without dwelling on and nitpicking little details.  For example, sure I could have used anonymous delegates as the callback methods, but that would have muddied the discussion.  Today, however, I'm going down that path :-)

I really like the generic QueryReader method that I proposed last month, but there are some issues with it:

  • The generic method uses a generic delegate callback.  However, using this mechanism you're required to have the callback method return a value of type T.  This isn't always desirous, especially if the callback method simply populates a control and doesn't want to burden itself with building a result set to return it only to have it iterated immediately to populate the control.  Sure, if the list is going to be used elsewhere and/or more generically, then it's great, but not 100% of the time.
  • Along with the previous point, you cannot call an instance of the method with T of type void.
  • If the callback method needs some information (e.g. state) on which to operate other than the data reader the signature needs to be enhanced.

To address these issues, I've made some changes and ended up with the following:

internal delegate T DataReaderCallback<T>(object state, SqlDataReader dr);
internal delegate VoidDataReaderCallback(object state, SqlDataReader dr);

internal static class DataAccess {
   internal static T QueryReader<T>(SqlCommand cm, object state, DataReaderCallback<T> callback) {
      SqlConnection cn = getConnection();
      SqlDataReader dr = null;
      try {
         cm.Connection = cn
         dr = cm.ExecuteReader(CommandBehavior.CloseConnection);
         return ( null != callback ) ? callback(state, dr) : default(T);
      }
      finally {
         if ( null != dr ) dr.Dispose();
         if ( null != cn ) cn.Dispose();
         cm.Connection = null;
      }
   }


   internal static void QueryReader(SqlCommand cm, object state, VoidDataReaderCallback callback) {
      SqlConnection cn = getConnection();
      SqlDataReader dr = null;
      try {
         cm.Connection = cn
         dr = cm.ExecuteReader(CommandBehavior.CloseConnection);
         if ( null != callback ) callback(state, dr);
      }
      finally {
         if ( null != dr ) dr.Dispose();
         if ( null != cn ) cn.Dispose();
         cm.Connection = null;
      }
   }
}

By implementing it as such, you have two overloads: one similar to before where the callback method returns a value and the second simply operates on the reader and is done - no return value is set.  Purists might identify that the 'state' parameter is typed as 'object' rather than generic or typed.  Ok, ok, if you want it, go ahead and make that change.

This now gives us the ability to do the following:

using ( SqlCommand cm = new SqlCommand("SELECT Name FROM Account ORDER BY Name") ) {
   VoidDataReaderCallback callback = delegate(object state, SqlDataReader dr) {
      while ( dr.Read() )
         cboAccounts.Items.Add(dr.GetString(0));
   };
   DataAccess.QueryReader(cm, null, callback);
}

Ok, so it's nothing earth shattering, but I like its simple elegance.

Tuesday, November 29, 2005 10:36:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [8]  |  Trackback
 Saturday, November 26, 2005

Well, it's finally happening.  DevUtah and Provo Labs (Infobase Ventures) are helping coordinate and put on a Geek Dinner.  The first of hopefully many of these Geek Dinners will be held on Wednesday, Nov 30th, 2005 from 6:00 PM to 8:00 PM at Los Hermanos Restaurantin Lindon.

For full details, please visit the DevUtah geek dinner announcement page.

Dr. Phil Windley will be the keynote speaker and will present on micro-formats and the writable web.

Please visit the website and RSVP - details are on the site.  See you there!

Saturday, November 26, 2005 3:35:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Wednesday, November 23, 2005

Alright, before railing on me about this and telling me how stupid it is to create this because a simple MSN/Google search would reveal tons of already-available solutions, I admit to having not found any that I really like.  I therefore took the liberty of creating two little .REG files that give you VS.NET 200x Command Prompt Here context menu shortcuts to the folder/drive/directory that you select.  There is a version for VS.NET 2003 and another for VS.NET 2005.

Feel free to download the .ZIP file here.  Simply run the appropriate .REG file by double-clicking it (you must have Administrator privileges) and wallah! (er, voila!) you have your shortcuts.  NOTE: these files will alter your system registry (though just slightly).  No guarantee is implied.  Just because it works great on my machine doesn't imply it will work universally, though I don't not see it working.

Note, both of these rely on their respective environment variables, notably %VS71COMNTOOLS% and %VS80COMNTOOLS%.

Very simple, I know, but effective and without all the other hassle and fluff...just simple, clean shortcuts.

Wednesday, November 23, 2005 4:21:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback