Thursday, September 30, 2010

Multiple Classes with RoleEntryPoint As The Base Class

When starting the Development Fabric for Windows Azure in Visual Studio 2010 are you getting this error:

 

Windows Azure Tools: Start role failed for one or more roles

Windows Azure Tools: Role instances did not start within the time allowed. Please try again. If you continue to encounter this behavior please try shutting down the Development Fabric.

 

In your output window? Or, maybe you are seeing these errors in your Windows Event Viewer under the application log:

 

The worker process for application pool '{B97C113B-B318-4AFC-84DA-XXXXXXXXX}' encountered an error 'The configuration section 'system.webServer/globalModules' cannot be read because it is missing a section declaration

' trying to read global module configuration data from file '\\?\D:\T\s0\deployment(2)\res\deployment(2).XXXXXX. WebRole.0\temp\temp\applicationHost.config', line number '0'. Worker process startup aborted.

Or:

 

Failed to initialize the AppDomain:/LM/W3SVC/1/ROOT

Exception: System.Configuration.ConfigurationErrorsException

Message: Exception of type 'System.Configuration.ConfigurationErrorsException' was thrown.

StackTrace: at System.Web.Configuration.ErrorRuntimeConfig.ErrorConfigRecord.System.Configuration.Internal.IInternalConfigRecord.GetLkgSection(String configKey)

at System.Web.Configuration.RuntimeConfigLKG.GetSectionObject(String sectionName)

at System.Web.Configuration.RuntimeConfig.GetSection(String sectionName, Type type, ResultsIndex index)

at System.Web.Configuration.RuntimeConfig.get_HostingEnvironment()

at System.Web.Hosting.HostingEnvironment.StartMonitoringForIdleTimeout()

at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel)

at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel)

at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)

at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)

I did, and it was because I had multiple classes in my worker role subclassed from RoleEntryPoint. You can only have one class per Worker or Web Role subclassed from RoleEntryPoint. Special thanks to Microsoft Customer Technology Support.  Hope this helps someone.

 

{6230289B-5BEE-409e-932A-2F01FA407A92}

Some new SQL Server Whitepapers

I receive permission to repost some white papers that I did this year for Microsoft, they are available below

  • Best Maintenance Tools for PTC Windchill on Microsoft SQL Server 2008 [PDF]
    • The majority of the content is generic and applies to almost any database running on SQL Server
  • Best Drive Configuration Practices for PTC Windchill on Microsoft SQL Server [PDF]
    • The majority of the content is generic and applies to almost any database running on SQL Server
  • Optimizing Fill Factor for SQL Server [PDF]
    • Going with the default fill factor and using GUIDs in indices is a dumb idea – it will often lead to 95% fragmentation of indices…
  • Using Management Data Warehouse for Performance Monitoring [PDF]
    • This is an ultra sweet component of SQL Server 2008. Imagine having performance monitor running always with all measures being recorded into a SQL Server database (including any custom ones you create). It exists and is part of SQL Server 2008. Learn about it and rule the bug reports!

Tuesday, September 28, 2010

Missing Windows Azure Assemblies

With all installations the developer needs to make sure that all the components to run the software are on the machine where their software is too run; Windows Azure is no exception. This article explains how to check all your assemblies before you upload using a Windows Azure Web Role that I wrote called Azure GAC Viewer.  The web role lists all the assemblies in the Windows Azure GAC and evaluates uploaded Visual Studio Project file; removing the guessing out of the process.

 

When I ship software as a running Windows application (think install on your desktop box), I check to make sure all the dependencies are either already on the box or installed as part of our installation; these include the right runtime libraries, third party DLLS, etc. Usually this is done with installation software like InstallShield.

 

With Windows Azure we need to make sure that all the assemblies that are not already installed on Windows Azure are included in the package that is uploaded to Windows Azure. What assemblies does your application have access to on Windows Azure? Only those in the global assembly cache and the assemblies uploaded in your package.

 

Secondary, we also need to make sure that we are not sending assemblies to Windows Azure that is already has, since this will make our packages bigger and increase our upload time.

The Problem

If Windows Azure can’t find all the assemblies that your code references it will not be able to load your application, nor will it be able to call any of the methods in your application. Basically the code cannot load into the process space. This means that any diagnostics calls in the application will not be called. It is very similar to running a Windows application where a DLL is present, no code gets called.

 

If you are missing an assembly your deployments will cycle between initializing, busy and stopping states.

 

To solve the problem: if your Windows Azure role relies on any assembly that is not part of the .NET Framework 3.5 or the Windows Azure managed library (listed here), you must explicitly include that assembly in the service package that you upload.

Visual Studio

Before you build and package your service, verify that: The Copy Local property is set to True for each referenced assembly in your project that is not listed here as part of the Windows Azure SDK or the .NET Framework 3.5, if you are using Visual Studio.

 

clip_image001

 

If you are not using Visual Studio, you must specify the locations for referenced assemblies when you call CSPack. See CSPack Command-Line Tool for more information.

A Faster Way

There is a faster way to check your Visual Studio project files just upload the .csproj or .vbproj file to this web site. It will parse the project file, check your references and report back anything that is missing. That way you don’t need to do a line by line comparison of all your references.

Summary

Do you have a better way to accomplish the same thing? Post it in the comments below. Do you have questions, concerns, comments? Post them below and I will try to address them.

 

{6230289B-5BEE-409e-932A-2F01FA407A92}

Windows Phone 7

Looking forward to Windows Phone Unleashed Developer Events

728x90_Banner_WP7DevLaunch[1]

{6230289B-5BEE-409e-932A-2F01FA407A92}

Wednesday, September 8, 2010

Calculating Optimal Fill Factors for SQL Server Indexes

Tonight I gave a presentation on SQL Server to the Bellingham .Net group that was well received.  The PDF of the PPT is at: http://lassesen.com/msdn/ProSQLServerTalk.pdf for those that missed the talk.

 

There are two formulas that I gave which I thought deserved a recap.

The first formula gives the optimal value for a batch setting where you are wishing the maximum throughput to occur for inserts. At the start, the throughput will be very high and then drop off as fragmentation takes over.

 

CREATE FUNCTION [dbo].[Fn_OptimalThroughputFillFactorForRandom] ( @KeyBytes float, @GrowthPercentage float ) RETURNS int AS BEGIN If @KeyBytes < 2 SET @KeyBytes=2 If @GrowthPercentage > 0.06 SET @GrowthPercentage = 0.06 If @GrowthPercentage < 0.001 SET @GrowthPercentage = 0.001 DECLARE @FillFactor float DECLARE @Rate float DECLARE @Offset float Set @Rate=- 5.2312 * Power(@keybytes,-0.244) Set @Offset=1 - 0.2193 * Power(@keybytes, - 0.462) Set @FillFactor= CEILING(100 * (@Rate * @GrowthPercentage + @Offset)) If @FillFactor < 50 SET @FillFactor=50 If @FillFactor > 99 SET @FillFactor=99 RETURN @FillFactor END

The second formula is when you wish to insure the best worst-case performance, typically seen on interactive systems. You want the response to be consistently good. This formula will have lower throughput at the start, but the level of throughput  is maintained relatively consistently until the end of period (when the index is defrag).

Create FUNCTION Fn_OptimalThresholdFillFactorForRandom ( @KeyBytes float, @GrowthPercentage float ) RETURNS int AS BEGIN If @KeyBytes < 2 SET @KeyBytes=2 If @GrowthPercentage > 0.06 SET @GrowthPercentage = 0.06 If @GrowthPercentage < 0.001 SET @GrowthPercentage = 0.001 DECLARE @FillFactor float DECLARE @Rate float DECLARE @Offset float Set @Rate=- 5.0189 * Power(@keybytes,-0.218) Set @Offset=1 - 0.9774 * Power(@keybytes, - 0.574) Set @FillFactor= CEILING(100 * (@Rate * @GrowthPercentage + @Offset)) If @FillFactor < 50 SET @FillFactor=50 If @FillFactor > 99 SET @FillFactor=99 RETURN @FillFactor END GO

As you will note, the fill-factor should never be set below 50%.