Bug fix - default path to ProfileCatalog.xml

Topics: CAB & Smart Client Software Factory
Sep 17, 2006 at 8:35 PM
originally posted by: MarkMBaker65

In Infrastructure.Library there is a class named ProfileCatalogModuleInfoStore. This class manages loading the catalog and is defaulted to look for the catalog in the file "ProfileCatalog.xml". In the method GetModuleListXml(), it uses the File class to read the XML and return it. This works well, except when the current or working directory is not the same as the EXE. A common situation for this is when a user double-clicks a file that is associated with the application and where that file is not in the same directory as the EXE. The code won't find the ProfileCatalog.xml and no modules are loaded.

Here is the fix:

public class ProfileCatalogModuleInfoStore : IModuleInfoStore
private string _catalogFilePath;

public ProfileCatalogModuleInfoStore()
_catalogFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"ProfileCatalog.xml");

Simply replace the _catalogFilePath line of code with the call to AppDomain.. and all is well.