Solved

Isolated Storage Question

Posted on 2003-11-03
6
531 Views
Last Modified: 2013-11-15
I want to use Isolated Storage but have two different .exe have access to the same isolated storage.  Is this possible?  

I could just write the exact path into the registry, but I would think there is a better way to do this.  There Isolated storage is storing files about preferences/profiles and what not.  Mulitple applications I am writing need to have acces to it.
0
Comment
Question by:jjacksn
  • 3
  • 3
6 Comments
 
LVL 6

Expert Comment

by:purpleblob
ID: 9674940
Yes it's possible to interact with a single isolated storage from multiple applications.

1. You need to use IsolatedStorageScope.User | IsolatedStorageScope.Assembly meaning that the any applications under the same user using the same assembly can access the isolated storage.

i.e.      
IsolatedStorageFile istore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);

2. Now this is a bit more messy. You can is essence have isolated storage so it's domain, user and assembly specific or user and assmbly specific. Now to use the assembly specific option you'll need a single assembly to interact with the storage.

3. Due to the location appearing to be part of the identification proces your applications will need to use an assembly from one location. For example placing all EXE's and the assembly into a single folder.

An alternative might be, and I've not tried this, that you could have the assembly which interacts with the isolated storage in a folder of it's own and then interact with it using reflection (by loading it into your appdomain) thus meaning you needn't have all EXE's in the same folder.

Not sure if this is the only (or best way) of achieving what you want, but it does appear to work

Hope this helps
0
 
LVL 5

Author Comment

by:jjacksn
ID: 9683567
I am not really familiar with the notion of an Assembly.  What is one?  How do I ensure that two .exes both belong to the same assembly?
0
 
LVL 6

Accepted Solution

by:
purpleblob earned 250 total points
ID: 9685147
Okay, well the MS help says

"An Assembly is a reusable, versionable, and self-describing building block of a common language runtime application"

But to put this in simply terms an EXE or a DLL is an assembly. It's not a case that both EXE belond to the same assembly but instead that both EXE's use the same assembly.

Okay, so to put this in real terms.

1. Create a Class library, this will create a DLL. Within the source for this class library put all you code for interacting with the isolated storage - now the code is in an assembly. Remembering that you use

IsolatedStorageFile istore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);

2. Create your two  EXE's and add references to your class library assembly/DLL.
3. Interact with the classes method to do your isolated storage stuff.
4. Now when working with isolated storage make sure you EXE's are either in the same folder as the assembly (the easiest way of doing this) or loads the assembly into the EXE's AppDomain at runtime.

Basically isolated storage appears to differentiate between assemblies, even if it's the exact same DLL but in different folders - therefore the folder is encodes into the isolated storage - if you run storeadm.exe usually stored within the folder C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin (if you're running VS 2003 otherwise have a look in the SDK folder and find the BIN) you'll see this. Note: storeadm is a console app. so you'll probably be best running it from a Command prompt.

Hope this helps, post back and I'll see what I can do :-)
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 5

Author Comment

by:jjacksn
ID: 9685206
Hmmm, that's worrysome, because that is precisely how my code is currently setup.  let me go debug...
0
 
LVL 6

Expert Comment

by:purpleblob
ID: 9685258
Oh an amendment to my previous email - I forgot this option. I haven't tried it myself but it certainly should also work. If you store the DLL/Assembly with the isolated storage functionality in the GAC you will not need to put each EXE in the same folder as the DLL (or each other) and this SHOULD (remember I haven't tested this) allow both EXE's to work with the DLL - this will be much simpler than using reflection and AppDomains to load this DLL up from some location or other.

0
 
LVL 5

Author Comment

by:jjacksn
ID: 9685278
ah, of course.  I'm debugging the two exe to different folders, so they are copying the dll.  This should all be fixed when I put them together.  thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now