Moving to Blogger…

 

I’ve moved this blog over to Blogger.  The new address is now: http://www.mcsdeveloper.com

Error using Themes to Skin Custom Controls in ASP.NET

I recently ran across a problem while trying to register a custom ASP.NET control on a themed page.  First I modified web.Config to register an assembly for use on any page or control in the site (take note of the namespace):

<system.web>
   <controls>
      <add namespace=”Insight.Web.CustomControls” tagPrefix=”custom” assembly=”Insight.Web”/>
   </controls>
</system.web>

Next, I created a theme named Insight and registered it site-wide in web.Config:

<system.web>
   <pages masterPageFile=”~/default.Master” styleSheetTheme=”Insight“>
</system.web>

Note that first segment of the namespace (Insight) matches the name of the Theme.  This will cause an error:

“Type Insight.Web.CustomControls.GridView is not defined”.

The type was defined just fine thank you very much, ASP.NET gets confused because part of the type name matches the name of the theme.  But you can fix this easily by just changing the name of the theme from Insight to something else (like InsightTheme):

<system.web>
   <pages masterPageFile=”~/default.Master” styleSheetTheme=”InsightTheme“>
</system.web>

And presto! No more error.  It’s best to set the default theme once in web.Config instead of on each page, making problems like this much easier to fix!

Visual Studio 2008 Setup Issues

Attempting to install VS 2008 RTM on my PC earned me the following error message:

“the following component failed to install: Microsoft Visual Studio Web Authoring Component”

Prior to the 2008 RTM, I had installed both the Orcas beta and a separate green bits version from Microsoft.  I got the green bits version for a Microsoft project I worked on that required the latest unreleased version of Orcas.  So I was expecting a problem or two just cleaning up the old stuff. 

I also run Altiris SVS which lets you install applications into isolated virtual layers.  But apparently all of the layers (applications) in SVS need to be deactivated for the Web Authoring Component to install.  It’s a weird and obscure fix that I would never have figured out without this kb article: http://support.microsoft.com/kb/933568

Just go into the SVS admin tool and deactivate all layers. VS 2008 should install without a hitch. 

Parsing Currency Strings – glitch in Microsoft’s Globalization framework (.NET 1.1 & 2.0)

I’m working on a currency localization feature in a banking application, and working through different ways to parse currency strings.  One way to do this is to call Decimal.Parse(), passing in the currency string and an instance of NumberFormatInfo, which specifies how the string is formatted.  Here’s an example:

Parsing Swiss Franks from a string to a decimal:

NumberFormatInfo infoSwissFranc = new NumberFormatInfo();
infoSwissFranc.CurrencyDecimalSeparator = “,”;
infoSwissFranc.CurrencySymbol = “SFr.”;
infoSwissFranc.CurrencyGroupSeparator = ” “;
Console.WriteLine(Decimal.Parse(“SFr. 1 111 111 110,11″, NumberStyles.Currency, infoSwissFranc).ToString());

Here’s another example that parses the Swedish Krona format:

NumberFormatInfo infoSEK = new NumberFormatInfo();
infoSEK.CurrencySymbol = “kr”;
infoSEK.CurrencyGroupSeparator = “-”;
infoSEK.CurrencyDecimalSeparator = “,”;
Console.WriteLine(Decimal.Parse(“111-111-110-11 kr”, NumberStyles.Currency, infoSEK).ToString());

Oops, the 2nd snippet doesn’t work.  In this case, assigning a value of CurrencyDecimalSeparator is not good enough.  You must also assign the same value to NumberDecimalSeparator as well, or an exception will be raised.  Apparently, this is only necessary if CurrencyGroupSeparator is a decimal (CurrencyGroupSeparator =”.”)  and the currency symbol is at the end of the string instead of the beginning.  Although setting NumberDecimalSeparator may be required when parsing when parsing numbers using NumberStyles.Number, it should not be required when NumberStyles.Currency is specified.  I could be missing something, but it looks like a glitch in the .NET framework. 

After adding NumberDecimalSeparator (in red), this code will successfully parse the Swedish Krona format:

NumberFormatInfo infoSEK = new NumberFormatInfo();
infoSEK.CurrencySymbol = “kr”;
infoSEK.CurrencyGroupSeparator = “-”;
infoSEK.CurrencyDecimalSeparator = “,”;
infoSEK.NumberDecimalSeparator = “,”;
Console.WriteLine(Decimal.Parse(“111-111-110-11 kr”, NumberStyles.Currency, infoSEK).ToString());

Microsoft Silverlight 1.1 Developer Reference Wallpaper

I created this wallpaper for my desktop from this image, courtesy of our friends at Microsoft.    It’s sized for 1920 x 1200 resolutions, with a solid black border around the top/left to make room for desktop icons.  Enjoy! 

Silverlight 1.1 Developer Reference Preview

An inspirational poster

sense.jpg

Sales Weasels

The sales weasels are at it again.  Sometime last week they set up a little mini-golf game behind my cube.  Every 20  minutes or so, a I hear a “whack!” and then a little ball will come tooling past my doorway.   There’s nothing like being snowed in with work, and hearing, “come on baby, hook! hook it! yeahhh!!!” just as you’re starting to figure out a complicated problem.

Developers’ Night Out

My team leader gathered all of us into the CEO’s office early this morning.  We learned that the company is not doing well, and we may be having a “Developers Weekend” to try and get more work done.  I’ve heard of events of this sort at large consulting firms, but have never experienced an all-weekend coding extravaganza for myself.   To make it fun, we can play music as loud as we want, and then go bowling or drinking afterwards.  But I hate loud music, bowling and drinking, and suggested that we just go home afterwards.  Maybe that’s not “team spirit”, but on weekends, I prefer to play for the “home” team.   Hey, I might as well be honest.

Bambi Eyes

I’ve learned that the “damsel in distress” effect is real.  My father-in-law once offered some good advice to one of his daughters whose car needed a small repair: park it next to the door at Advance Auto Parts, raise the hood, and wait!  Plenty of help was soon offered to her.

A comely young damsel recently joined our firm and wasted no time asking pretty much everyone for help.   She made her way to the cube next to me today, and I overheard: “hey, do you know anything about site maps?”  “Me? Yeah yeahyeahyeah,” came the reply.  “Great! can you show me?” she said.  ”Um… um… Lemme see here, I think, yeah… watch this!”  

What followed for the next 30 minutes was so disgusting that I got no work done until it was over.   Mr. fleet fingers was happily banging out code for his damsel.  A few minutes would pass before she would say something motivational:  “wow… what a great site map!”  And then: “wow… I don’t have to do any work now!”   And so it went.

When it was finished, she came over to my cube and said, “hey, YOU never write code for me!”.  And honestly, I felt a little guilty.  If she were a guy, she would have no job. 

Must.. make… client…. happy…..*

I have posted nary a thing since early this month, but I have a good excuse!  But first, a question for you:

In consulting, is it possible to make a client too happy?  Whenever there is an agreement between buyer and seller, the overall goal is always that both parties walk away satisfied.  But if party A is drastically more satisfied than party B, then chances are it’s because the project was underbid by party B, who I work for.

If you answered yes, then you probably have worked for on projects that somehow quietly crept out of scope and nobody noticed until it was too late.  Decision makers probably told the developers to try to do whatever it takes to “cram” those extra features in there, and avoid disappointing the client. 

Or, in my case, the scope was well defined during the planning phase, and a detailed estimate submitted.  But lo and behold, after all of this work, the client announced that someone in sales had predicted it shouldn’t cost more than $50,000.  So our schedule / timeline is currently based on that number, and not the true cost of the project.  Our CEO is somewhat infamous for keeping the client happy at all costs.  But I would argue that if the consulting firm is losing money, the client might be too happy.

Unless they are cash strapped, clients will respect consultants that communicate genuine risks, and will sometimes agree to pay more if need be to ensure a successful project.

All that to say… I’ve been working a little overtime lately.