Tag Archives: tips

SharePoint error when activating publishing feature: the trial period for this product has expired

On some of my SharePoint 2007 farms, when I tried to activate the publishing feature, I got this error:

The trial period for this product has expired.

I was certain that my license had not expired, so I did some research on Google. I found that it was a known issue that affected Microsoft Office Servers product with service pack 2.

My SharePoint farms had been patched to version 12.0.0.6535 (SP2 + December 09 cumulative update), so they were affected.

The solution was to install Microsoft KB971620. It required a server reboot after installation.

Centralized exception handling

Exception handling is a very useful mechanism to improve a program’s robustness. In case an unexpected exception occurs, developers commonly write a code block as follows:

try
{
  // Do something
}
catch (Exception ex)
{
  // Log the exception
  // Notify the user about the exception
}

That code block is very often duplicated everywhere in the project. It is obviously not a good coding practice. Instead of duplicating, we should extract and promote it as a subroutine. That way, we can gain the following advantages:

  1. More maintainable; if the exception handling is kept in a single place, it is easy to apply future modifications.
  2. More productive; less amount of code to write (or copy) means less coding time and less possibility of error.
  3. Separation of concern; each routine will be much clearer since it is not polluted with exception handling, logging, and notification code blocks.

Centralized exception handling implementation

If you already have or willing to use Microsoft Enterprise Library, there is already the Exception Handling Application Block for you to use.

But you can easily implement your own. The basic idea is create a method with your exception handling block. This method must be able to accept and execute a code block. To achieve this we can use delegate. In .NET Framework 3.5, it is even simpler with the Action delegate.

The code executes inside the try block, while in the catch block, all necessary treatments (logging and notification) can be added.

The following is a sample skeleton of the implementation built as a method called TryExecute:

void TryExecute(Action code)
{
  try
  {
    code(); // Execute the passed code
  }
  catch (Exception ex)
  {
    // Log the exception
    // Notify the user
    // Add more things as required
  }
}

Then, in your client code, you can just call it as follows:

void SomeMethod()
{
  // Send the code inside the block to the TryExecute() method.
  TryExecute(() =>
  {
    // Do something
  });
}

Easy, right?

InfoPath 2010 breaks SharePoint 2007 installation

Last time I wrote that the stsadm -o copyappbincontent command didn’t work if you had installed Office 2010 on the same machine with your SharePoint 2007. Later I found the same problem on more scenarios:

  1. When running the stsadm -o copyappbincontent command.
  2. When attaching a content db to Web application.
  3. When running the psconfig command or running the SharePoint Products and Technologies Configuration Wizard application.
  4. The SharePoint’s upgrade.log file is missing.

When you perform any of those operation, you will get the following error message:

One or more types failed to load. Please refer to the upgrade log for more details.

The message told you to refer to the upgrade log. Ironically, the upgrade.log file is missing from the logs folder.

Previously, I thought the solution is uninstall the whole Office 2010 suite. But apparently, uninstalling InfoPath 2010 is enough to solve the problem.