Fixing the Volume Shadow Copy service

After installing DHCP on Windows Server 2008 R2, you may start to see the following error message in the event logs :

Volume Shadow Copy Service error: Unexpected error calling routine RegOpenKeyExW(-2147483646,SYSTEM\CurrentControlSet\Services\VSS\Diag,…). hr = 0×80070005, Access is denied.

Inspection of the detailed tab of the event log entry will show information about the process that generated the error. Take note of the user mentioned after the “- User: Name:” portion of the bytes. To resolve this error, simply give that user full permission to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\VSS registry key.

Fixing the DFS Namespace service

After you install Active Directory on Windows Server 2008 R2, you may start seeing the following error message after the server boots :

The DFS Namespace service could not initialize cross forest trust information on this domain controller, but it will periodically retry the operation. The return code is in the record data.

This occurs because the DFS Namespace service attempts to access Active Directory before it has completely initialized.

To resolve this issue, we simply have to force the DFS Namespace service to start after the Active Directory service has initialized. We can do this by setting the DFS Namespace service to depend on the Active Directory service as well as setting it to a Delayed Startup mode.

To make those changes, start regedit and make the following changes :

  1. Navigate to the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Dfs
  2. Modify the DependOnService value and add NTDS to the list.
  3. Create a new DWORD value named DelayedAutostart and set its value to 1.

Storing IPv4 Addresses for Performance

When designing tables, it is important to take into consideration the impact that your choice of columns and its data types will have on performance. The list of data types available has also been growing, making design choices even more difficult. Often real world data is not optimized for performance and it is necessary to find methods of transforming this information to allow efficient storage within tables that take both speed and size into consideration.

Read the full article

Determining the Order of ASP.NET MasterPage and Page Events

Anyone who is a regular ASP.NET developer is likely familiar with the ASP.NET Page LifeCycle diagram that Kris van der Mast posted on his blog more then 3 years ago. It is indisputably the best reference when trying to determine where to insert your code in the life cycle of your pages. There is however a lack of clarity on where MasterPages fit into the picture. With a bit of logging and digging, here’s a diagram which illustrates clearly in which order MasterPage and Page events are fired. If you’re deriving a custom MasterPage or Page class for your site, the diagram also shows the relation between your class code and the automatically attached MasterPage and Page events.

Continue reading ‘Determining the Order of ASP.NET MasterPage and Page Events’ »

Disown your ASP.NET children

If you’re building a site that contains nested applications, you may find yourself confused at what appears to be IIS completely disregarding your virtual directories. The behavior is by design. Although the applications will get isolated, the web.config settings from parent applications propagate to children applications. An easy fix is to simply wrap your web.config with the following to disable propagation :

  <location path="." inheritInChildApplications="false">
    <system.web>

    ...

    </system.web>
  </location>

Most sections can be wrapped at the exception of <configSections>, <runtime> and of course, the <configuration> root node.

Check out the full article on aspdotnetfaq.com for more details.

Linus Torvalds supports Microsoft’s initiative

It didn’t take long for the entire world to learn about Microsoft’s submittable of 20,000 lines of code for the Linux driver base. As a surprise reaction to both sides of the camp, Linus Torvalds responded in favor of Microsoft’s move. I have a feeling that the most memorable portion of his response will become this little snippet :

I may make jokes about Microsoft at times, but at the same time, I think the Microsoft hatred is a disease. I believe in open development, and that very much involves not just making the source open, but also not shutting other people and companies out.

Turn your ASP.NET pages into valid XHTML Strict pages

Many developers seem to find it difficult to get their ASP.NET pages rendering in a valid XHTML Strict fashion. The solution is just a quick MSDN lookup away. Only two steps are required.

One, declare the proper XHTML Strict DOCTYPE :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Two, edit your Web.Config file and the following to the System.Web section :

<xhtmlConformance mode="Strict"/>

ASP.NET will now adjust the HTML it outputs from controls and get rid of the infamous name attribute on the form tag.

Extending the SqlDataAdapter with a FillTimeout

The SqlDataAdapter has a CommandTimeout property but does offer any method to set any kind of timeout during the Fill method. If you are returning rather large data sets, you can quickly run into a problem. The obvious solution would be to inherit the SqlDataAdapter and simply override the Fill method, except that the SqlDataAdapter cannot be inherited. As a result, we must implement the same methods that the SqlDataAdapter does and attach them to a private internal SqlDataAdapter to do all the heavy lifting. With the use of anonymous delegates, we can easily rework the Fill methods to offer a new FillTimeout property and throw an exception when we exceed our desired timeout.

Continue reading ‘Extending the SqlDataAdapter with a FillTimeout’ »

Improved ASP JSON utility

Most of the projects that I have been working on lately did not require any advanced AJAX. Most of the time, stuffing the results of a simple GET into innerHTML has usually been sufficient. Recently, I needed to do some more advanced AJAX work so I started looking into JSON. There a hundreds of helper classes that people have dreamed up already for ASP.NET, however this project was under the Classic ASP (VBScript) umbrella.

I fell upon a nice little utility on aptly called aspjson. It is a nice utility except the implementation of multi-dimensional array support is flawed. Try to JSON an array that has dimensions with more than 10 elements and you will quickly see what I mean.

I rewrote the multi-dimensional array support from scratch and I am releasing the code under the same license as the original author as well as obviously attributing credit to Tuğrul Topuz for his original code.

Download the ASPJSON 2.1 source

Fixing Dreamweaver CS4′s JavaScript Events for XHTML

One of the first things you learn about XHTML is lowercase. Everything is lowercase. Lowercase tags, lowercase attributes, lowercase, lowercase, lowercase…

I guess it wasn’t obvious enough to the developers over at Adobe because Dreamweaver CS4 has this annoying habit of mix-casing all of the JavaScript event handlers.

Continue reading ‘Fixing Dreamweaver CS4′s JavaScript Events for XHTML’ »