Silverlight Isolated Storage Settings Being Overwritten by Another Silverlight Application - silverlight

I have a Silverlight application deployed on both our staging and production servers. This application caches information using isolated storage settings. If I browser to
http://stagingserver/pagewithsilverlight.aspx
everything works fine, data is stored to isolated storage on my machine just fine. However if I browse to
http://productionserver/pagewithsilverlight.aspx
everything works EXCEPT that nothing is saved to isolated storage on my machine. Both pages contain copies of the same xap file. Why would it behave one way when hosted on one server and behave a different way when hosted on a different server?
Edit: Additional note, I have verified that data is not being saved to isolated storage by looking at the C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Silverlight\is directory while running my application.
Edit #2: After further investigation (process monitor), the data is being written to isolated storage, but then being overwritten by another SilverLight application on the same page. This didn't show up on our staging environment since the second application was not deployed there. Somehow, both applications are being given the same isolated storage location. They are unique xap files, so how are they being given the same IsolatedStorage.ApplicationSettings location?

Could it be that your applications are using GetUserStoreForSite() instead of GetUserStoreForApplication() on the IsolatedStorageFile class?

Related

Why cloud application's file system is ephemeral

The "Beyond 12 factor APP" and "Considerations for Designing and Running an Application in the Cloud "(https://docs.cloudfoundry.org/devguide/deploy-apps/prepare-to-deploy.html)
states file system is ephemeral.
However I got different result when testing with openstack:
create VM using openstack server create with centos qcow2 image, no
external storage
ssh to the VM, create file under /home/centos
reboot VM
after VM startup, the file is still there.
Did I understand something wrong?
quote from the book:
cloud-friendly applications don’t just run in the cloud;they embrace
elastic scalability, ephemeral filesystems
in the "Logs" chapter: Cloud applications can make no assumptions about the file system on which they run, other than the fact that it is ephemeral.
quote from "Considerations for Designing and Running an Application in the Cloud " :
"Avoid Writing to the Local File System": "Local file system storage is short-lived."..."When an application instance crashes or stops, the resources assigned to that instance are reclaimed by the platform including any local disk changes made since the app started. When the instance is restarted, the application will start with a new disk image. Although your application can write local files while it is running, the files will disappear after the application restarts."
The meaning is that when running containerized applications you can't trust the file system to be longed lived between restarts, as it may be purged, or you might be running next time on a different instance.
It doesn't mean the data is guaranteed to disappear - just that it isn't guaranteed to stay - very much like a temp folder on a regular server
ephemeral(non-persistent) storage is given by default to the guests, if persistent storage is required for the apps, Cinder can be used.

Best Practice for Location of Java JSP Application Files in Tomcat Environment

My Java JSP application requires to store permanent files on the Tomcat web server. At the moment I save the files in the "/temp" folder of the System. But this folder gets cleared from time to time. Further, the current solution is hard-coded which makes it less flexible (e.g. when moving to another server).
I would like to now if there is a best practice for defining and accessing a permanent directory in this configuration. In detail, where is the best place to define the app file directory, and how would I access this from within my java application? The goal of this setup would be to cause the least effort when (a) updating the application (i.e. placing a new war file), and (b) moving from one server to another and OS (e.g. Unix, Windows, MacOS).
The research I have done on this topic so far revealed that the following would be solutions (possibly amongst others):
1.) Use of a custom subdirectory in the Tomcat installation directory.
What happens to the files if I deploy a new version on the tomcat via
war file?
Where do I define this directory to be accessed from
within my Java application?
2.) In a separate directory in the file system.
Which are good locations or ways to get the locations without knowing
the system?
Where do I define this directory to be accessed from
within my Java application?
Thank you for your advice!
Essentially, you are creating 'a database' in the form of some files. In the world of Java EE and servlet containers, the only really general approach to this is to configure such a resource via JNDI. Tomcat and other containers have no concept of 'a place for persistent storage for webapps'. If a webapp needs persistent storage, it needs to be configured via JNDI, or -D, or something you tell it by posting something to it. There's no convention or standard practice you can borrow.
You can pick file system pathname by convention and document that convention (e.g. /var/something on Linux, something similar on Windows). But you won't necessarily be aligned with what anyone else is doing.

HTML5 client-side database location

I want to create a standalone todo list with HTML5. Ideally, it would be a file that sits on a USB drive and could leverage a database (either embedded in the html file somewhat like tiddlywiki) or would access another file.
I've read about Web SQL and SQL Lite, but it seems like they save the database information to a specific location on the local computer, and the user has no control over whether to place it elsewhere. The app wouldn't really be portable if it saves a different instance for every machine upon which it's run.
Is there a solution to force the database to reside on the portable drive?
Client & Server Storage
SQLite
SQLite is a database engine that needs to be specifically installed on a machine or packaged with software. This type of technology is usually used on the server side with a server programming language like PHP. Therefore, I do not believe that server storage solution is for you.
HTML5 Client Storage
Meanwhile, Web SQL is an HTML5 feature for client storage. The databases are managed by the client (the browser) through JavaScript. The implementation of WebSQL is very similar to SQLite. Note that Firefox supports IndexedDB instead of WebSQL. Sadly, you can't force the browser to store the databases onto an external drive.
The Solution
At this point, the most viable solution for you is to create an application that will be executed on the external drive. If you really want to use HTML5 you could go with Titanium. It leverages the power of web technologies to create native cross-platform applications. From Titanium's documentation you can package a SQLite database with your application.

How to side deploy a XAP w/o clearing Isolated Storage?

I've noticed that when deploying a XAP to my device via Visual Studio 2010 that it does not clear/erase the Isolated Storage for that application. However, when using the stand-alone Application Deployment program, it does erase the Isolated Storage.
The reason why I ask, is that I'm using dotfuscator & runtime intelligence, so I need to build, dotfuscate, then deploy with AppDep, but then my application data is gone. I realize that I could get around this by setting up the dotfuscator to run via command line in the post-build scripts, and then deploy w/ VS, but for now let's assume that I don't want to do that.
Does anybody know how to deploy a XAP the way VS 2010 does it, so that it doesn't erase Isolated Storage? I'm hoping there's a command line program I can run.
AFAIK there is no way around this. The deployment tool first uninstalls and then re-installs the app, so isolated storage gets wiped. The same is true when deploying from Visual Studio after selecting the Rebuild All or Clean Build -> Build options.
There are a couple of ways around this:
Use Isolated Storage Explorer, this will let you browse, upload and download files to isolated storage.
Setup a WCF / web service service to connect to and transfer files to and from the app
Write a bunch of initialization code in the app that can be triggered to create all the files you need
I've generally been checking for DEBUG and then running a method that sets up my test data, etc.
ie-
#if DEBUG
SetupTestData();
#endif
//load like normal now that test data's set up.
To make this really easy, on occasion, I've also just used the app to generate the data I want to use from then on, then Debug.WriteLine(...) my XML or similar method to dump it.

Silverlight OOTB Support for 'Save File' browser dialog

I am in the design stage of an application that must be both a standalone app & a web application (To save the costs of building 2 near identical applications twice). Basically I have opted to go for a silverlight OOTB application that will be installed on the standalone machines and they will write to a collection of files in the sandbox and occasionally talk to the server version. The same application (with a little configuration) will also operate on the webserver and store its data in a database.
I am however more of a WPF developer so I would like to cover some concerns I have before I go too far down this path...these are:
I hear you can pass a file out for the user to 'Save As' in their browser when using SL normally. Is there similar functionality with OOTB? Because I want to be able to save some of the local files to locations other than the sandbox (With user permission)?
Is is possible to configure OOTB to allow access to the filesystem outside of the sandbox?
Is there a way to programatically determine whether a silverlight application is running in OOTB mode (So I know what mode the application should be running in)?
Are there any major flaws in my ideas so far that would prevent this from being a possibility?
Silverlight 4 will provide support for out of browser trusted applications, which have more privileges that a normal sandboxed application but still not as much as a regular desktop application. Regarding file access, a trusted application will be able to access to some predefined folders such as MyDocuments, MyMusic, MyPictures, MyVideos, but not the entire filesystem. See here for details: http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-trusted-applications.aspx
As for how to know whether you are running out of browser or not, use Application.Current.RunningOffline.
Finally, I recommend you to take a look at PRISM. Among other things, it eases the task of sharing code between WPF and Silverlight, so you could consider developing a dual SL+WPF application.

Resources