Monday, December 15, 2008

Master Page Error (AJAX 1.0 / .NET 3.5)

If you have a .NET 2.0 site that is using AJAX 1.0 and you change the project to .NET 3.5, your web.config file gets modified. Then, when you try to look at any page that references the master page file, you will get this error:

Master Page error
The Master Page file '~/MasterPage.master' cannot be loaded.
Correct the problem in Code View

Basically, it rewrites the "sections" with the updated assemblies for AJAX in .NET 3.5. To fix this immediately, return your site to a .NET 2.0 site, and update your web.config file using this (just look for and replace the "sectionGroup" sections):

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>

Monday, December 8, 2008

SQL Server - Cannot attach a database that was being restored

This was a fun error. We had an extremely large database (450 GB) that was in the process of restoring and got hung up in SQL Server 2005. Each time we would try to attach the database, it would fail because it kept thinking it was "being restored". So, after you take some aspirin, be assurred that there is a way to "trick" SQL Server.

  1. Create a new database with the same name as the one you are trying to attach.
  2. (optional) Detach the database, and then move the MDF and LDF files to the specific drives that you need.
  3. (optional) Reattach the database from it's new location. You will have to update the paths to the LDF file when restoring.
  4. Take the database Offline.
  5. Copy your original MDF and LDF files and overwrite the newly created files.
  6. Bring the database back Online.

Wah-la! It's back!

If this didn't work for you, you may have something more severe on your hands like a corrupt database file.