473,394 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Having trouble with IsolatedStorage persistence in .NET

Hi there,

I'm working on a Windows application in C# and wanting to persist MDI window states so that when a user opens the application, it looks like it did when they closed it down.

I've been using the IsolatedFileStorage to save a class with the settings in it. I've set breakpoints in the program and watched as the correct values are supposedly 'saved' in the IsolatedFileStorage location. But then when I load them back from the file, some of the values are not coming back correctly from the file.

Any ideas on what I might be missing here? Below is a snippet of some the code...

Thanks,
Pete

Expand|Select|Wrap|Line Numbers
  1. private ModuleSettings windowmodulesettings = new ModuleSettings();
  2. [Serializable()]
  3. public class WindowSettings
  4.     {
  5.         public bool Initialized = false;
  6.         public int Top =0;
  7.         public int Left =0;
  8.         public int Height =0;
  9.         public int Width =0;
  10.         public bool Visible = false; 
  11.     }
  12.  
  13.     [Serializable()]
  14.     public class ModuleSettings
  15.     {
  16.         public WindowSettings Window1 = new WindowSettings();
  17.         public WindowSettings Window2 = new WindowSettings();
  18.  
  19.     }
  20.  
  21. private void LoadModuleSettings()
  22.         {
  23.             IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly();
  24.  
  25.             IsolatedStorageFileStream isfs1 = 
  26.                     new IsolatedStorageFileStream("WindowSettings.xml", 
  27.                     FileMode.Open, FileAccess.Read, isf);
  28.  
  29.             BinaryFormatter BF = new BinaryFormatter();
  30.             windowmodulesettings = (ModuleSettings) BF.Deserialize(isfs1);
  31.             isfs1.Close();
  32.         }
  33.  
  34. void SaveModuleSettings()
  35.         {
  36.                     IsolatedStorageFile isf =
  37.                         IsolatedStorageFile.GetUserStoreForAssembly();
  38.  
  39.                     IsolatedStorageFileStream isfs1 = 
  40.                         new IsolatedStorageFileStream("WindowModuleSettings.xml",
  41.                         FileMode.Create, FileAccess.Write, isf);
  42.  
  43.                     BinaryFormatter BF = new BinaryFormatter();
  44.                     BF.Serialize(isfs1,windowmodulesettings);
  45.                     isfs1.Close();
  46.         }
  47.  
Sep 5 '08 #1
2 1496
Oops - the two filenames above are not the same - I changed the filename for the purpose of posting this question. However, they are the same in the actual file I'm using... sorry....
Sep 5 '08 #2
Got it working now... the trouble wasn't with IsolatedStorage - rather it was that the SaveModuleSettings function was being called multiple times....
Sep 5 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: PerfectDayToChaseTornados | last post by:
Hi All, I'm interested in peoples opinions & experiences of various persistence frameworks. I mainly use EJB2 or straight JDBC for persistence, but have been looking at various alternative...
6
by: Paolo Losi | last post by:
Hi all, I'm pretty new to the python language so please excuse me if this is FAQ... I'm very glad to be part of the list! :-) I'm looking into a way to implement a generic workflow framework...
1
by: Simon Chester | last post by:
Hello! Can anyone help me with this problem?... I have developed an ASP.NET (version 1.1) application which I have deployed to a number of webservers. The web application works fine on Windows...
1
by: Joe | last post by:
I was wondering if there are any recommended persistence frameworks for use in .NET that could be recommended. I am looking for the following requirements: Free/Open Source or very inexpensive....
10
by: Simon Harvey | last post by:
Hi everyone, Can anyone tell me if I declare a global variable in my pages code behind, is it persisted if the page does a post back, or do I need to add the object to the session object in...
0
by: Zdenek Drlik | last post by:
Hi, I have an ASP.NET application. I want to use IsolatedStorage in this application. When I run this application with anonymous access set in IIS (user set to IUSR_<machine>) and impersonation...
2
by: dkode | last post by:
Hello, I am laying out the architecture for a very large website that will scale to a very large degree. I have a couple of questions before I attempt to go and implement a Broker/Persistence...
5
by: Chris Spencer | last post by:
Before I get too carried away with something that's probably unnecessary, please allow me to throw around some ideas. I've been looking for a method of transparent, scalable, and human-readable...
1
by: Mythran | last post by:
We are using the P&P Enterprise Library Application Blocks in our applications and I'm reviewing how the EL stores it's cached data. As I was looking through the implementation of the security...
0
myusernotyours
by: myusernotyours | last post by:
Hi all, Am trying to create a Java Desktop App that uses Java Persistence in Netbeans. The database is MS Access but I tried with Mysql and got the same error. When I run the app( Create the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.