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.
Related
I am currently building a WPF application and have some system wide settings. Where is the best place to store these settings? App.Config file, Database or some other sort of XML file? (need to read and write).
My other issue is the application has two states (i.e. Admin Mode, Client Mode) and depending on the state the application behaves differently i.e. (Shut Down, Restart, Lock, Unlock etc.) This seems like a good case to implement the State design pattern... but the issue I am facing is that the running application is itself the context class. I am a bit confused... should I be implementing the Singleton Pattern? How is this best implemented?
In general it is often easiest to store application settings using the Settings page of the Project Designer in Visual Studio. These settings can either be stored per user or per application. Either way, they can be saved easily by calling:
Properties.Settings.Default.Save();
They can be accessed similarly:
Properties.Settings.Default.FirstUserSetting = "abc";
You can find out full details by taking a look at the Managing Application Settings page on MSDN.
Regarding your second question, I would recommend using the State Design Pattern. Unfortunately, I didn't understand your problem with that, so please let me know what your issue is and I will try to address it.
Could you please tell me is there any way to display Isolated-storage path using In-browser type silverlight5 application.
The full path to the isolated storage is normally not programmatically retrievable, at least not in Silverlight.
It is not possible to access m_AppFilesPath member in the IsolatedStorageFile instance through reflection, since the field is private. If you try to do this, you are likely to receive FieldAccessException.
If you are looking for the file system location of the isolated storage files and directories, please read this SO answer.
If you want to find out the file paths relative to the isolated storage root when running your application, AFAIK there is only the GetFileNames methods in the IsolatedStorageFile class, preferably in combination with GetDirectoryNames.
It is in principle possible to request the relative file path of a specific file as well by accessing the Name property of the IsolatedStorageFileStream object, however this property is only available in trusted applications.
Would it be possible to get the isolated storage location in a WPF app? I'm having problems with a customer using VDI (Virtual Desktop Infrastructure). Sometimes the isolated storeage will work and sometimes it doesn't. Seems like it's random and I want to try to debug this.
They're using a roaming user account.
I'm trying to make a Silverlight app which has a local sqlite file to search some data when the app gets offline. I found the following library, http://code.google.com/p/csharp-sqlite/ and it seems pretty nice.
So, what I want to know is, what is a good approach to have and place a file which might be replaced by automatically when the data in a server gets updated at some points?
I've tried to put a file into a folder under the app, but I couldn't access to the file by using csSQLite.sqlite3_open (This method is from the library above). Sorry, I'm pretty new to Silverlight, so my question might be very odd.
Thanks in advance,
yokyo
It doesn't look like this library has been specifially coded for Silverlight. Despite being a pure C# implementation its still likely to assume the full .NET API is available. This is not true in Silverlight.
Specifically Silverlight cannot ordinarily access the local file system. The SQLLite code would need to be modified to understand Silverlight's IsolatedStorage. It would also have to limit its file operations to those that are supported by the streams available Isolated Storage.
The creation of a DB-esq. data source in Silverlight is typically done by create Classes the represent records and collections of records, using LINQ to query them and Xml serialisation into Isolated storage to persist them.
Here is a hacked version of the SQLite code to work with Silverlight, you can use it for some ideas on what to do: http://www.itwriting.com/blog/1695-proof-of-concept-c-sqlite-running-in-silverlight.html
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
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).