GetUserStoreForDomain Fails

Jul 9, 2010 at 10:03 PM
Edited Jul 9, 2010 at 11:57 PM

When loading a Fluent Ribbon Application from another application GetUserStoreForDomain fails.  For example:

 Dim w As New Fluent.Sample.Foundation.Window()
 w.ShowDialog()

Error:

An exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.dll but was not handled in user code

Additional information: Unable to determine the identity of domain.

In Ribbon.cs, the issue is resolved by adding additional checks to determine if the AppDomain.CurrentDomain.ActivationContext is valid.  If the value is null, you can load the storage file from the Assembly.  This resolves the error.  We recommend adding this to the Fluent.dll.

        void LoadState()
        {
            if (!AutomaticStateManagement) return;
            IsolatedStorageFile storage = null;
            if (AppDomain.CurrentDomain.ActivationContext != null)
            {
                storage = IsolatedStorageFile.GetUserStoreForDomain();
            }
            else 
            {
                storage = IsolatedStorageFile.GetUserStoreForAssembly();
            }
            if (FileExists(storage, "Fluent.Ribbon.State.dat"))
            {
                using (IsolatedStorageFileStream stream =
                    new IsolatedStorageFileStream("Fluent.Ribbon.State.dat",
                                                    FileMode.Open, FileAccess.Read, storage))
                {
                    LoadState(stream);
                }
            }
            // Now we can save states
            IsStateLoaded = true;
        }

The SaveState function also needs the above:
        void SaveState()
        {
            // Check whether automatic save is valid now
            if (!AutomaticStateManagement || !IsStateLoaded) return;
            IsolatedStorageFile storage = null;
            if (AppDomain.CurrentDomain.ActivationContext != null)
            {
                storage = IsolatedStorageFile.GetUserStoreForDomain();
            }
            else
            {
                storage = IsolatedStorageFile.GetUserStoreForAssembly();
            }
            using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("Fluent.Ribbon.State.dat", FileMode.Create, FileAccess.Write, storage))
            {
                SaveState(stream);
            }
        }

Coordinator
Jul 10, 2010 at 3:38 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Aug 5, 2010 at 2:26 PM
I am having the same issue. Has it been fixed?
Coordinator
Aug 5, 2010 at 3:02 PM
It will be fixed in v2