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!

SQL Server Analysis Services Connection Errors

Ever get the below error when trying to connect to Analysis Services?  From the looks of things at forums.microsoft.com, lots of folks do. 

An error has occurred while establishing a connection to the server. when connecting to SQL server 2005, this failure may be caused by the Fact that under the default settings SQL Server does not allow remote connections.

The problem is the account that the “SQL Server Browser Service” uses to authenticate, which by default is the account selected for services during setup.  But this account needs to have administrator rights.  So if the “Network Service” account is used, the quick fix is to change the SQL Server Browser Service to run as “Local System” instead.  Have a look at this Books Online article for details on the minimum rights required for the browser service to work properly – you’ll want this account to have the least permissions required in a production environment.

But according to Microsoft: “To work properly, the SQL Server Browser service must run under a security account that has local administrator rights, such as the local system account.” (Pasted from http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/CISQL2005ASCS.mspx)

This seems a bit ambiguous to me.  The books online article recommends using minimum permissions, but the technet article says you have to use an admin account.  On my laptop, the browser service appears to have all of the recommended rights, but will not let me connect until I run as Local System.  Strange but true.

Note: The SQL Server Browser Service in (SQL Server 2005) is only necessary when using named instances or a side-by-side installation with SQL Server 2000.  Otherwise, SQL Server setup does not configure the browser service to start automatically.

Business Intelligence Resources for SQL Server 2005 and PerformancePoint Server 2007

I’m attending an Advanced BI Training course this week.  Below are some books and online resources recommended by the instructor.  

Books:

Web Sites:

Tools:

  • BIDS Helper : “A Visual Studio.Net add-ins with features that extend and enhance the functionality of the SQL Server 2005 BI Development Studio. (BIDS)”

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. 

Decoding SharePoint error messages

I had just activated a new feature on a WSS 3.0 site, and attempted to add one of its Web Parts to a page, when up came a helpful error message:

“The Web Part you attempted to add no longer exists in the Closed Web Parts Gallery.  Refresh your browser to update the Web Part Page and the Gallery.”

But the problem is that I attempted to add an Ajax web part to a page without first installing ASP.NET Ajax.  Daniel Larson said it best: “This is the WORST error handling ever.” This error message offers almost no help.  Daniel Larson’s blog post on the other hand, was a big help (many thanks)!

 

image

 

This brings to mind another infamous SharePoint error message that appears after modifying any aspect of a “ghosted” page with SharePoint Designer, which moves the page to an “unghosted” state (i.e., the page is moved from disk into the content database) and causes the page to be executed in Safe Mode.  If any inline scripts are in the page, you might see this friendly reminder:

“An error occurred during the processing of /SomeDir/SomePage.aspx. Code blocks are not allowed in this file.”

This message makes sense after you’ve seen it a few times, but isn’t very helpful if you’re new to WSS, and making even a trivial change breaks your page.  Modifying web.config to always allow server scripts to run is a quick and dirty fix for this one:

<PageParserPath VirtualPath=”/*” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=”true” />

But a better (more secure) approach would be to create a custom server-side control, and explicitly register it as safe in web.config :

<SafeControl Assembly=”MyApp, …” Namespace=”MyApp.Controls” TypeName=”*” AllowRemoteDesigner=”True” />

I suspect Microsoft is letting developers write their own error messages, which might explain why they read like code.  As long as people keep blogging their solutions though, I’m happy.

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());