brenth

COM error when loading a serverstyle

Discussion created by brenth on Apr 23, 2012
I am getting the following exception when trying to add a style file to a StyleGalleryStorage object.

Error HRESULT E_FAIL has been returned from a call to a COM component.

There is no other information.  The file in styleFile is verfied that it exists.  What can be the issue?


            IStyleGallery styleGallery = new ServerStyleGalleryClass();
            IStyleGalleryStorage styleStorage = styleGallery as IStyleGalleryStorage;
            string styleFile = System.IO.Path.Combine(styleStorage.DefaultStylePath, 
                "ESRI.ServerStyle"));
            try
            {
                styleStorage.AddFile(styleFile);   //line sending the error...
            }
            catch(Exception ex)
            {
                  ....


More info:  It only crashes if the DefaultStylePath is Engine10.0.  It seems to work if the DefaultStylePath is Desktop10.0.

Outcomes