Tuesday, June 14, 2011

Gallery Server Pro 2.5 Released

Today I released Gallery Server Pro 2.5.0, featuring new support for Microsoft SQL Server Compact 4.0 (SQL CE), an improved upgrade experience, faster SQL Server performance, and numerous bug fixes. The compiled and source code versions are available for immediate download. The Web Platform Installer version has been submitted to Microsoft and should be approved within a few days. The DotNetNuke Module will be available in a few days as well.

Upgrading the gallery

The upgrade wizard has been revamped to make it even easier to upgrade your gallery. If you are currently using version 2.4 under .NET 4.0, all you have to do is copy the files from the upgrade package over your existing installation and then browse to the gallery. The upgrade wizard automatically appears and guides you through the process. If you are running an earlier version of .NET or are upgrading version 2.0 – 2.3, there are a couple more steps which are described in the Admin Guide.

The upgrade wizard automatically removes the cachingConfiguration section in web.config, which is no longer needed. (Caching is now done with the .NET 4.0 MemoryCache class.) It also deletes these DLLs from the bin directory:

  • AjaxControlToolkit.dll
  • System.Data.SQLite.DLL
  • Microsoft.Practices.EnterpriseLibrary.Caching.dll
  • Microsoft.Practices.EnterpriseLibrary.Common.dll
  • Microsoft.Practices.ObjectBuilder.dll
  • GalleryServerPro.Business.Wpf.dll
  • GalleryServerPro.Data.SQLite.dll
  • TechInfoSystems.TracingTools.dll

If you integrated the gallery into an existing site that requires one or more of these assemblies, be sure to save a copy and then restore them when the upgrade is complete. Similarly, if your site uses the caching functionality from the Microsoft Enterprise library, you will need to restore the cachingConfiguration section in web.config.

New SQL CE data provider

Earlier this year Microsoft released Microsoft SQL Server Compact 4.0. Prior to this release, it could not be used in ASP.NET applications. Microsoft spent a lot of effort making it work in a multi threaded environment like ASP.NET, and it now offers all of the benefits SQLite provided – such as XCOPY deployment and no external dependencies - while offering a few significant bonuses:

  • A single package for 32-bit and 64-bit operating systems – SQLite had a dependence on System.Data.SQLite.dll, which came in 32-bit and 64-bit flavors, necessitating a download package for each type of OS. While SQL CE also must be distributed with 32-bit and 64-bit versions of its engine, Microsoft figured out a way to have both of them deployed in the bin directory so we don’t have to worry about it.
  • Works in medium trust – SQLite only worked in full trust, forcing users in reduced trust environments to use SQL Server, which is more difficult to set up and maintain and not supported by some hosts. And when it is supported, it is often an extra cost option.
  • Increased data integrity – SQLite did not do type checking to verify, for example, that an integer is really being stored in the AlbumId column, nor did it enforce referential integrity. SQL CE does both.
  • Officially supported by Microsoft – SQLite has a robust user community, but the release of SQL CE pretty much eliminates any compelling reason to use SQLite. I expect that interest in maintaining the SQLite ADO.NET provider will shrivel up.

Gallery Server Pro uses Entity Framework 4.1 Code First and LINQ to communicate with the database. This technique allowed me to crank out the provider in a fraction of the time it took me to write all that ADO.NET code used in the SQLite and SQL Server providers.

One of the biggest benefits is that I was able to update the Web Platform installer version of Gallery Server Pro to use SQL CE instead of SQL Server. By switching to SQL CE, the installation process became much simpler because it no longer has to install SQL Server. I know a lot of users tried to install GSP through the gallery but got hung up with a SQL Server issue, usually something to do with logon credentials or not finding the database server. Those problems all disappear.

SQL Server is still fully supported. If you prefer to use it, be sure to download the install package instead of using the WPI.

Where is SQLite?

SQLite is no longer supported in 2.5 as I could not justify the effort in maintaining the provider. During the upgrade process, your SQLite data is imported to a SQL CE database file named GalleryServerPro_Data.sdf in the App_data directory. When the upgrade is complete, the old SQLite file at App_Data\galleryserverpro_data.sqlite is no longer used and can be deleted or archived.

If you were using SQL Server, you will continue to use SQL Server in 2.5.

.NET 4.0 requirement

Moving to SQL CE and EF Code First required changing the system requirements to .NET 4.0. This move brought a lot of side benefits:

  • Ability to use native .NET 4.0 caching instead of the Microsoft Enterprise Library, allowing us to get rid of the cachingConfiguration section in web.config and the three DLLs it required.
  • Use of LINQ. This simplifies certain kinds of coding patterns.
  • Elimination of multiple web.config files. Previous versions of GSP shipped with six – count ‘em – SIX versions of web.config for use in various .NET environments and trust levels.
  • Elimination of separate WPF assembly. I was able to integrate the WPF functionality – used for enhanced metadata extraction – into the business layer.
  • Reduced test matrix. Testing the code base on multiple .NET environments was time consuming.

Faster SQL Server performance

As I was refactoring the code to use the Entity Framework, I noticed opportunities for improving the performance of several areas. These improvements affected both data providers, but are especially noticeable when using SQL Server. The greatest improvements are in galleries having thousands of users or tens of thousands of media objects. This was achieved in three main ways:

  • Re-architecture of the maintenance algorithm that runs during each application restart.
  • Improving the algorithm that maps user roles to albums.
  • Using ordinal positions when retrieving data from a data reader. For example, using dr.GetInt32(0) instead of Int32.Parse(dr["AlbumID"].ToString(), CultureInfo.InvariantCulture).

jQuery 1.6 compatibility

When jQuery 1.6 was released on May 3, it introduced a breaking change that affected a few of the pages in the site admin area. At the time, I blogged about a workaround where you tell GSP to use the older version of jQuery. The new version of GSP fixes those issues, so after the upgrade you can point jQuery back to the original value “//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”. Do this on the Site Settings – General page.

In fact, you have to do this, since the fix requires jQuery 1.6. Specifically, GSP uses the new prop() function. If you don’t point to the latest version of jQuery, you may discover problems in a few areas, such as the inability to navigate media objects using the Next and Previous buttons.

Code analysis

The code analysis feature of Visual Studio 2010 was used to implement coding best practices. I had run this a couple years ago but much of the code has changed and it was time to do it again. Nothing serious was found but I did make hundreds of changes. Most changes fell into these categories:

  • Perform parameter validation at function entry points and throw an ArgumentException and ArgumentNullException as appropriate.
  • Include an IFormatProvider when processing strings and numbers.
  • Ensure Dispose() is called on all disposable objects. I was already doing that on most but I had missed a few.

Elimination of Ajax Control Toolkit

GSP has used the Ajax Control Toolkit to provide a few impressive UI effects, such as fading when navigating between media objects and creating interactive HTML DOM elements. However, the industry has recognized that jQuery is a better option and has largely abandoned the toolkit. Furthermore, versioning issues have always been a hassle. GSP now uses jQuery for effects previously handled by the toolkit.

Fixed bugs (detailed report)

  • Watermark image is locked by IIS process
  • Watermarked image sometimes fails to be rendered
  • Thumbnail image not generated for PDF files
  • Paging doesn't work on search results page
  • Deleting the root album results in "Album not found" message
  • Incompatibility with jQuery 1.6.0
  • Blank page may appear when error occurs
  • (SQL Server) Delete unnecessary foreign key from gs_Album table
  • (Sql Server) Length of MIME type columns different between gs_BrowserTemplate
    and gs_MimeType
  • (DotNetNuke) Album treeview navigation doesn't work when user-friendly URLs are
    disabled

1 comment:

Dave Burke said...

You're making all the right moves. No 32x/64x issues, removal of some fat DLLs, including AjaxControlToolkit (smart!), .NET 4.0 and better performance. Congratulations on another great release of Gallery Server Pro!