Thursday, June 23, 2011

Gallery Server Pro Binary Pack Updated

The Gallery Server Pro Binary Pack adds additional functionality to your gallery, such as thumbnail extraction from videos, TXT, PDF, EPS, and PSD (Photoshop) files. The pack consists of three open source components – GhostScript, ImageMagick, and FFmpeg. They are free and easy to install. The only requirement is that your site must be running in full trust to take advantage of them.

Today I updated the pack to include the latest version of each utility (GhostScript 9.02, ImageMagick 6.70, FFmpeg 0.8). Download it here. To update your existing components, copy the contents of the bin directory in the download to your bin directory, then run the GhostScript setup program. I don’t know if you need to uninstall the previous version of GhostScript first – as a safety precaution you may want to.

Tips for upgrading to Gallery Server Pro 2.5

Since releasing 2.5.0 a couple weeks ago, I am pleased the upgrade is going smoothly for the vast majority of you. However, a few support issues seem to be repeating themselves, so I wanted to throw out some tips to help it go smoothly.

Back up before upgrading – Make a backup of your database and web files before the upgrade. That way, in case anything goes wrong, you have something to revert to.

.NET 4.0 required – Version 2.5 requires .NET 4.0, so be sure it is available. I recommend getting your 2.3 or 2.4 gallery running on .NET 4.0 before upgrading to 2.5. The Admin Guide has all the details – read it carefully.

SQLite to SQL CE migration errors – There have been two users who reported issues in the upgrade step that migrates data from the SQLite database to the SQL CE database. In one case, data in the Comment column of one of the aspnet_Users records had to be deleted before the upgrade would succeed (it was actually quite mysterious because the data didn’t *look* corrupt). In the other case, there were two records in the aspnet_Roles table that referred to an application that didn’t exist in the aspnet_Applications table. Since SQL CE enforces referential integrity – and SQLite does not – this caused the migration to fail. The fix was to delete the two records from SQLite and run the upgrade again.

In other words, you might have to clean up the SQLite data a bit to make it “fit” in SQL CE. If you have trouble, read the error message carefully for clues, then use a tool like SQLite Administrator to find and fix it. If you really, really get stuck, send it to me (roger*at*techinfosystems*dot*com) and I can take a look (make sure you provide details with as much info about the error as possible).

jQuery 1.6 or higher required – In early May, jQuery released 1.6, which broke backward compatibility with earlier versions. At the time, the workaround was to temporarily change your jQuery version to a pre-1.6 version. Gallery Server Pro 2.5 fixes the issues by using the new jQuery 1.6 prop() function (instead of attr()). Of course, this means 2.5 isn’t compatible with jQuery 1.5 and earlier. If you try to use jQuery 1.5 in GSP 2.5, the two main issues you’ll notice are broken next/previous media browsing and broken UI functionality in several of the site admin pages.

This means that after you upgrade your gallery, one of your first steps is to make sure you are referencing jQuery 1.6 or higher (on the site settings page). I recommend using the value “//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”, which will use the most recent 1.* release available.

If for some reason you must use jQuery 1.5, you can revert to the old behavior by replacing all instances of “.prop(“ with “.attr(“. That needs to be done in these files: gs\pages\admin\gallerycontrolsettings.ascx, gs\pages\admin\metadata.ascx, gs\pages\admin\usersettings.ascx, gs\script\mediaobjectview.js, and gs\pages\admin\manageroles.ascx.cs. Note that the last file (manageroles.ascx.cs) is a code file and is only found in the source code version. Once you update it, you will need to compile it and deploy a new GalleryServerPro.Web.dll to your bin directory (the assembly is named TechInfoSystems.GalleryServerPro.dll in the DotNetNuke module).

DotNetNuke users – This jQuery gotcha is especially important for you, since most installations of DNN are using a pre-1.6 version of jQuery. Probably the easiest way to update your site to the latest version of jQuery is to select the “Use hosted jQuery version” checkbox in the Advanced Settings/jQuery section of the Host Settings page. This will automatically use the latest 1.* release of jQuery available, assuming the hosted jQuery URL settings is still at its default value of “//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”.

SQL CE editor – With SQL CE 4 just being released, there really isn’t an excellent, simple, and free tool available to let you see and edit the data directly in the database. I expect that to change in the coming months as SQL CE picks up speed. For now, there are a few options, and I describe them in the Admin Guide. Look for the section Management Tools for SQLite, SQL CE and SQL Server.

Apply the patches – A patch is available that fixes a few bugs in the 2.5.0 release.

Be on the lookout for new errors when extracting metadata – Version 2.5 incorporates the WPF-based metadata extraction technique directly in the business layer, whereas earlier versions were invoked via reflection in a separate DLL (this provided enhanced metadata for users running .NET 3/3.5 while still working on servers running only .NET 2.0). The reflection-based technique had a side benefit in that all errors were wrapped in a special exception that GSP chose to ignore (after first logging it), preventing files with metadata corruption from causing any visible trouble.

Version 2.5 directly calls the metadata extraction code, so any errors that aren’t caught cause the file upload or synchronization to fail. Microsoft recommends against using global exception handlers to silently catch all errors, so what I need to do is add little catch blocks that catch each type of exception that may occur. However, I have no idea what those are until you tell me. That has happened twice a few times now, and I’ve updated the patch accordingly.

If you didn’t understand that techno-speak – what I am saying is this: If you get an error while syncing or uploading files, post a thread in the forum with all the details (look in GSP’s error log if necessary). I can’t fix what I don’t know about.

Deleted DLLs – One of the nice things about 2.5 is that it no longer needs several DLLs, so it deletes them during the upgrade:

  • 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

Obviously, if you are using GSP in a site that requires one or more of these assemblies, be sure to save a copy and then restore them when the upgrade is complete. I imagine the most likely DLL you need to preserve is AjaxControlToolkit.dll.

Note: The DNN upgrade won’t delete any DLL’s, so you don’t have to worry whether another module might need one of these assemblies.

Also, the ugprade wizard might find that it can’t delete one or more DLLs it wants to. In my experience, this is most likely System.Data.SQLite.DLL. If you discover this file still exists in your bin directory after the upgrade, you may delete it.

Tuesday, June 21, 2011

Patch For 2.5.0 Released

Edit: 2011-06-23 – added fixes for two new issues.
Edit: 2011-06-28 – added fixes for two more issues.
Edit: 2011-07-12 – added fixes for four more issues.
Edit: 2011-08-01 – added fix for one issue.
Edit: 2011-08-05 – added fix for one issue.

Today I released a patch for 2.5.0 to fix a few bugs that came to light after its release. The patch includes fixes for all three variants of Gallery Server Pro – the stand-alone version, the WPI version, and the DotNetNuke module.

To apply the patch, first make sure your site is running 2.5.0. Then download the patch and navigate to the folder that pertains to your flavor of GSP (stand-alone, WPI, or DNN). Copy the DLLs it contains to your bin directory. That is it – you do not have to restart IIS or go through an upgrade wizard.

Download the patch here. Here is what is fixed:

  • Viewing error log generates "String was not recognized as a valid DateTime" error – This may happen when the server has a non-US culture.
  • An ArgumentNullException may be thrown during an auto-sync – I believe this happens only when one or more of your images contain GPS data.
  • (DotNetNuke only) Error when anonymous browsing is disabled for a gallery and an anonymous user attempts to view it
  • (added June 23) Error "Property cannot be found" when adding or syncing an image
  • (added June 23) Error "Object must be initialized before operation can be performed" when adding or syncing an image
  • (added June 28) Error "Unexpected property type or value" when adding or syncing an image
  • (added June 28) ArgumentException or InvalidOperationException when adding or syncing an image
  • (added July 12) Error FileNotFoundException occurs during a synchronization
  • (added July 12) Error OverflowException when adding or syncing an image
  • (added July 12) User given incorrect confirmation message after rotating images
  • (added July 12) Wrong MIME type may be sent to browser for some media objects
  • (added August 1) Nothing happens when you click the Browse button on the Add objects page when using IE 9 in DotNetNuke 6.0.
  • (added August 5) A timeout error in FFmpeg interrupts synchronization

These fixes will be included in the next official release.

Friday, June 17, 2011

Fix for SQL Server users

Today I identified a bug in the SQL Server provider where it does not correctly handle roles that have been assigned to multiple albums. The package downloads have been updated, so if you downloaded 2.5.0 before today, grab the latest GalleryServerPro.Data.SqlServer.dll from the install or upgrade package and replace your version.

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

Upgrading your gallery to .NET 4.0

Gallery Server Pro 2.0 – 2.4 runs on any version of .NET from 2.0 - 4.0. Beginning with version 2.5, Gallery Server Pro requires .NET 4.0 or higher. This change allows GSP to take advantage of new features such as Entity Framework Code First development for SQL Compact CE and LINQ, while also simplifying the packaging and documentation requirements. (You may have noticed that 2.4 ships with six versions of web.config!)

If you are currently running GSP 2.3.* or 2.4.*, I recommend upgrading your gallery to .NET 4.0 *before* upgrading the gallery code to GSP 2.5. Technically, you could perform the .NET 4 upgrade and the GSP 2.5 upgrade at the same time, but why complicate things? By separating it into two steps, if anything goes wrong, it will be easier to troubleshoot.

What if you are using GSP 2.0 – 2.2? Those versions never shipped with a .NET 4.0 version of web.config, and I don’t think it is worth the trouble trying to get them working under .NET 4.0 only to immediately upgrade to GSP 2.5. For these versions, I recommend performing the upgrade to .NET 4.0 and GSP 2.5 at the same time. The Admin Guide has instructions for how to do this.

The rest of this post is intended to help you get your GSP 2.3 – 2.4 gallery running under .NET 4.0. This basically involves two steps:

1. Configure IIS to run the application under .NET 4.
2. Update web.config to conform to .NET 4.

Configure IIS to run the application under .NET 4.

This step is performed with IIS Manager (type inetmgr in a Start-Run box). For IIS 6, right click the gallery web application and choose Properties. Then click the ASP.NET tab and select 4.0 in the ASP.NET version dropdown box.

For IIS 7 and higher, the .NET version is associated with the application pool the application is running under. In IIS Manager, select the Application Pools node in the treeview, then double-click the relevant application pool in the grid. A dialog appears where you can change the .NET Framework version to 4.0. If you don't know which app pool the gallery is running under, right-click the name of the application in the treeview and select Manage Application - Advanced Settings. This brings up a dialog window that shows the app pool.

If you are using a hosting provider, look in your host’s control panel for this setting.

Update web.config to conform to .NET 4.

The web.config file, stored in the root of the web application, contains several references to a specific version of .NET. These must be updated to .NET 4.0 references or, in some cases, removed since they are now present in the machine-wide web.config file. Follow these steps:

  1. Rename your existing web.config to web_old.config.
  2. Grab the relevant web.config from this download and copy to your web application. For example, if you have version 2.3 with SQLite as your database, use web.config from the “Files for upgrading from 2.3\SQLite” directory.
  3. (SQL Server only) Update the connection string to your SQL Server database in web.config with the one from your previous one (now named web_old.config). It should be named SqlServerDbConnection.

Notes

  • If you made any changes to your web.config file, you must manually migrate them to the new web.config file.
  • If your version is 2.3.3421 to 2.3.3512, you should also migrate the <location path="gs/services/Gallery.asmx"> section from your old web.config file. (This section is not required in 2.3.3512 and later, as there is a web.config file in the services directory that performs this task.)
  • You are on your own if you want to get GSP 2.0 – 2.2 working on .NET 4.0. It can be done, but you have to carefully upgrade your web.config to the .NET 4.0 version. As I said before, for these versions I recommend upgrading to .NET 4.0 and GSP 2.5 in a single step. Instructions are provided in the Admin Guide.