Can two Silverlight applications share IsolatedStorage on one machine? - silverlight

What identifies an silverlight application and when can two silverlight applications share IsolatedStorage if at all, i.e.:
if I want to have two Silverlight applications share IsolatedStorage space, is this possible? What kind of "application id" do I need to give to do this?
if I don't want two Silverlight applications to share IsolatedStorage, how do I prevent this? Do I need to do this?
For instance, I've noticed when I develop a Silverlight application, I can press F5, in the application save to Isolated Storage, stop the application, press F5 again, and it reads from the same IsolatedStorage. (I would think that a new compilation would cause it to use new IsolatedStorage.)
However, when I then copy the .xap and .html files to another directory and open the .html file, it does NOT share the IsolatedStorage with the application I was developing. What changed?
What is going on behind the scenes here so I know when IsolatedStorage is shared and when it isn't?

The URL to the source XAP file identifies the application. You would want a new version of an application to be able to read the existing store for a previous version. Consider a game where all the high scores are stored in the application store. The user might be a little upset when all those scores disappear after they upgraded it.
Different applications can share a single site based store. However you only get those two levels of granularity, app level keyed at the XAP Url or site based, which is host and port (I'm not sure whether scheme is also part of that key).

If memory serves me right the isolated storage can be used within the scope of the application and scope of the page. So - if I understand my recollection right, I'd probably say - yes.
Edit
From a copy of Pro Silverlight 3.0 in C# that I posess :
(p. 636)
With isloated storage, a niqe storage location is created for every combination of user and application. In other words, the same computer can have multiple isloated storage locations for the same application, assymin each one is for a different user. Similarly the same user can have multiple storage locations one for each Silverlight Application
(p. 637)
... GetUserStoreForFile(). This method provides a storage site that's accessible to all silverlight applications on the same website domain, however these settings are still user specific

Related

Loading a new Silverlight application from isolated storage

Is there any way i can load a silverlight application from isolated storage and replace the current application ?
Short answer: no, you cannot do this. You could however store a dll, read and load it via reflection if you are in a trusted out-of-the-browser application.
Anyway I don't believe this to be a very good practice, it's very likely there is a different better way to solve your particular problem.
You can't replace the currently running application from within Silverlight code.
However you could create a single application to act as a shell. You could store assemblies or entire Xaps in isolated storage. Using the AssemblyPart class allows you to load an assembly from this storage, create an instance of an entry type and execute an entry point method.
The big caveat would be that this "stored application" would have to be coded specifically to work within your shell. You would need to provide your ways in particular to allow for "application" level state to be accessed and a means of loading content assets such as images.

In Browser Silverlight Application - Client Side File/Directory access

When building a Silverlight 4 application is it possible to get a directory listing from an in browser application?
It seems the SaveFileDialog does not have the capability to set the file name of the file being saved, so I thought that I could create my own user control, however it seems that is not possible as I can't get a directory listing in an in-browser application.
I realize that certain well known directories are accessible from Silverlight 4 in out-of-browser application, but that doesn't help an in-browser application.
In-browser Silverlight apps are constrained by the sandbox, so from a file I/O perspective it's not much different from SL3 in the sense that you really have no access to the file system outside of Isolated Storage. Of course, a user can specify whatever directory they want to save a file in but you cannot specify it for the user - it's 100% the user's call on where a file is stored, and client-side file storage outside of Isolate Storage must be user-initiated.

Is Silverlight isolated storage treated as permanent, or as a cache?

How persistent is isolated storage - does Silverlight treat it like a cache, deleting items when it needs more space, or only when the user or application request it?
There also seems to be a wide variety of means to identify isolated storage - machine, application, domain, .... What I'm having trouble with is how these all relate to the user. Is it possible, and if so how, to create and later retrieve an isolated storage file with the following properties:
The same file is used, regardless of which Windows user is logged in
The same file is used, regardless of the assembly version (updates to the xap). Instead the url would remain constant. This would have to work even offline (out of browser).
Basically I want the isolated storage to persist across application updates, and over different users logging in.
It is fairly permanent. The user could delete it if they really wanted too, but they would have to go out of their way to do so.
Here is the MSDN documentation for Isolated Storage.
IsolatedStorageFile in Silverlight a couple of statics that let you choose where you want to scope the storage:
GetUserStoreForApplication
GetUserStoreForSite
The "MachineStore" options are not available in Silverlight, there are just "Application" and "Site". Both are scoped by the user..since the files are stored under the user's AppData on Windows. Apps in-browser and out-of-browser share the same Isolated Storage stores.
[edit..I missed part of your question the first time]: The Isolated Storage stores are not part of the browser cache, so they are not cleared when the browser cache is cleared. As a developer, you can delete things programmatically. As a user, you can use the Silverlight configuration UI (i.e. the right-click menu) to manage the stores - it's called "Application Storage" to the user. Finally, an intrepid user can locate the files on disk and delete them manually...they are hidden so they won't show up in a normal search, but a determined user can still find them.

WPF to silverlight: what about files-IO?

We have a working WPF app that we are looking into running in the browser via Silverlight. The big question mark right now is; what kind of file access will we have (without jumping thought to many hoops)?
Can we open server-side files?
Can we open client-side files?
Can we get change notification on files (client or server side)?
Can we do the normal open/seek/write/append operations?
(Good link welcome as answeres)
This looks relevant for the client side stuff, as with the follow up/correction
Haven't found anything about loading file from the server.
Server Side Files : No, unless you serve them via a web service.
You can open files in two ways. One is isolated storage, an area that your application has, of limited size (although you can ask the user for an increase). In this you can read, write and do what you want. If you want hard disk access then you can only read, and the file must be opened from a file open dialog.
If you mean via a FileSystemWatcher - no, not even in isolated storage. Server side you can do what you want, obviously, because it's not Silverlight there. You can use duplex web services so the server could notify your silverlight application when something happens like a file change.
In isolated storage you can do what you want. Outside of that it is read operations only and the user must choose a file from the File Open dialog.
Make it XBAP and deploy it as full trust
What kinda app are you having???? first tell that and we can work the conclusions out!
UPDATE
WPF Internet Sandbox Feature List
(XBAPS & Loose XAML)
Windows Presentation Foundation
Security Sandbox
Silverlight
File access problems
You won't be able to manipulate local files with silverlight without rich client side component. That client side componetn must expose web service API and behave like local web server. With that aproach you can do almost everything that regular WPF app can do.
"Can we open server-side files?" - Yes, but requires a web service (edited)
"Can we open client-side files?" - Yes, only via an Open File window or files in isolated sotrage
"Can we get change notification on files (client or server side)?" - Yes, but only on server side.
"Can we do the normal open/seek/write/append operations?"
With System.IO.FileStream class, which is available in Silverlight, you can manipulate textual streams in memory. However, you need to fetch the stream by web services, opening it with file open window, or from isolated storage.

Silverlight MVVM Isolated Storage

I've tried to use IsolatedStorageSettings in my ViewModel, but these are not getting retained across browser refreshes (F5).
for example;
//look in the IsoStore for remembered details
IsRememberMe = IsolatedStorageSettings.ApplicationSettings.Contains(Constants.LOGIN_REMEMBERED_USERNAME);
if (IsRememberMe)
{
UserName = IsolatedStorageSettings.ApplicationSettings[Constants.LOGIN_REMEMBERED_USERNAME] as string;
}
Do I need to do something differently in my MVVM ViewModel's??
EDIT
It's worth noting that this code is sitting in a referenced project - so ultimately a seperate XAP file to the parent XAP that is loaded in the browser - might this cause the settings to be lost on each refresh?
THanks,
Mark
Well...
In my case I have issues using Application Isolated Storage, each time I deployed a new version of my app (just for instance changing the color of a button I lost my Iso Storage :-().
I move to use SiteStorage instead of Application level, and it worked:
http://www.tipsdotnet.com/TechBlog.aspx?PageIndex=0&BLID=13
On the other hand what I had done with Iso Storage is perform CRUD on folders and files, not sure abou that other kind of settings.
HTH
Braulio
I would think one of two things is happening here. Either your binding isn't working correctly in both directions so either the persistence or the retrieval code is never hit. Or, you're storing these values in application level iso storage from two different applications (or something to that effect). Make sure your code is being hit in both cases (storing and retrieving) and make sure you're accessing the iso store from the same place (if you're using application level isolation, store/retrieve from the same application, etc).

Resources