Friday, July 20, 2007

Trust the docs, except when they are wrong

I've been getting quite a few reports that my 5.0 and 5.1 installers don't work on Vista.  The reports all say that near the end of the install, it errors out with an error code of 2869. 

As a side note, I have yet to have an MSI error code that had a description that I  understood.  The description is almost always something like 'The transaction failed to start'.  These descriptions don't tell me anything.  But I digress.

This 2869 issue was hard to reproduce and very random.  After some work I found a 32 bit Vista machine that showed the problem.  With some trial and error and installutil style debugging I discovered that the problem was in my custom installer class.  Inside the MySql.Data assembly, we have a custom installer class that does two things.  First it adds the assembly to the system's machine.config file and then it adds a couple of performance counters.  With some additional testing, I found that the performance counter code was failing. 

The code calls PerformanceCounterCategory.Exists() to determine if the category already exists.  This call was throwing a FormatException with the message 'The input string was not in the correct format'.  Now if I check the handy dandy docs for this method, it clearly tells me that this method might throw one of three exceptions (ArgumentNullException, ArgumentException, or Win32Exception).  How is anyone supposed to make sense of a FormatException that is generated deep inside the bowels of the framework? [This is the reason for the blog title, BTW]

I found a blog post that referred to using the PerformanceCounterInstaller class.  The surface area of the .NET framework never ceases to amaze me.  I've been using it now for > 4 years and I still discover new classes almost weekly.  Thinking I had solved my problem, I replaced my code with calls to this new class.  Nope.  Still the error remains.  Back to Google.

Finally I discovered others who had this problem and found out that the registry information for the performance counters can become corrupt and read about the 'lodctr' tool.  This tool has a parameter (/R) that restores the registry settings either from a file or from the system store.  Running lodctr /R on the affected systems rolls the perfmon registry settings back to the latest system store but solves the FormatException problem when trying to install new performance counters.

7 comments:

  1. Reggie, I'd be interested to learn more about these performance counters. Are they new? I'm not seeing anything MySQL-related in perfmon on my machine with the 5.0.7 connector installed.

    ReplyDelete
  2. Jeffrey

    They should be installed as collectors. Did you try creating a dataset and adding a collector? They should be listed along with Sql Server and Oracle.

    ReplyDelete
  3. Register your own WordPress blog here!

    ReplyDelete
  4. hi there! Nice topic. Welcome to hallowen!

    ReplyDelete
  5. Most popular soft for youtube video.
    http://thetubesoft.com/

    ReplyDelete
  6. Very interesting stuff

    ReplyDelete
  7. Wow! Thanks for this... I was tearing my hair out trying to get the MySql Connector installed. Cryptic error message, no information on the MySql site, obviously no help from MS.

    Your blog was the only site I could find that had a solution.. and so simple

    Lodctr /R

    Thanks!

    ReplyDelete