IsolatedStorageFile.GetUserStoreForAssembly() when Major Vers chan

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have used Isolated Storage to store some user preferences, and now for
'non-technical reasons' our Major version number has changed on our
Assemblies.

But I do not want all users to lose their preferences, so I would like to
find a way to read the 'old' IsolatedStorage for version 5.2.2.2 of my
assembly from the 6.0.0.0 version code.

Isolated storage has this nice feature of giving you a new isolated storage
when the major version of the product (assembly) changes.. - but I need to
temporarilly bypass this feature.. (since I already saved the preferences
using GetUserStoreForAssembly in version 5.x)

I have tried code like the following:

I get an "Execution permission cannot be acquired" on the call to GetStore()
when I am passing my constructed evidence for the previous version of the
assembly. Is this because the previous version of the assembly is not
currently loaded ? - does it have to be loaded to use its 'evidence' ?

Does anyone have any ideas how to solve this general problem of reading the
Isolated storage of a previous version of the assembly ?

I think perhaps I should use a different method of opening the Isolated
storage in the future - does anyone have an example of how I could obtain
Version _Independant_ isolated storage based just on the simple name of the
assembly. (I guess I am looking for the opposite of the previous discussion
here on how to obtain completely version _Dependant_ Isolated storage..)

Thanks for any clues, hints or comments on similar attempts.

John F.


===
// Get the isolated store for this assembly - this is the original way -
but this isolated storage changes when major version changes,

IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly();


// now try to get the isolated storage for the previous version 5.2.2.2
- so we don't lose it when they upgrade.
Byte [] mybytes;
int discarded;

mybytes =
HexEncoding.GetBytes("00240000048000009400000006020000002400005253413100040000010001000948995ae0b97702f4618ab704f5c138ca4ca9dec812590a64584c0244b1e0bbd05f11932199576e47d82bc5ee22ad40ea706348db50f90c49f55b8a11645d0fe748d01e115cbef570453f9d6f43a1655ae6d155f59c70ba6ea9f88f660c7343f25b4b5b7a3ba78893b26c880bc1529f56edc3aaf6ca9bea2ab2e7501fc875be",out discarded);


System.Security.Permissions.StrongNamePublicKeyBlob mypublickey = new
System.Security.Permissions.StrongNamePublicKeyBlob(mybytes);


System.Security.Policy.StrongName mysn = new
System.Security.Policy.StrongName(
mypublickey,"AccountableSoftwareInc.AnyViewInstall.DatabaseInstall",new
Version(5,2));

System.Security.Policy.Evidence myEvidence = new
System.Security.Policy.Evidence(null,null) ;

myEvidence.AddAssembly(mysn);

// next line throws exception : Execution permission cannot be acquired

//IsolatedStorageFile isf_oldversion =
IsolatedStorageFile.GetStore(IsolatedStorageScope.Assembly,null,null,myEvidence,typeof(System.Security.Policy.StrongName) );

===
 
I tend to provide an Export and Import function to the user, so he can
save/restore his/her settings from isolated storage to/from a file of its
own choosing for backup purpose. He can also then restore the latest backup
after a version change or if he use another account.

Besides that, you can try to dig below "Document and Settings\User\Local
Settings\Application Data\IsolatedStorage\...\AssemFiles\..."

/LM

John Frandolig said:
Hello,

I have used Isolated Storage to store some user preferences, and now for
'non-technical reasons' our Major version number has changed on our
Assemblies.

But I do not want all users to lose their preferences, so I would like to
find a way to read the 'old' IsolatedStorage for version 5.2.2.2 of my
assembly from the 6.0.0.0 version code.

Isolated storage has this nice feature of giving you a new isolated
storage
when the major version of the product (assembly) changes.. - but I need to
temporarilly bypass this feature.. (since I already saved the preferences
using GetUserStoreForAssembly in version 5.x)

I have tried code like the following:

I get an "Execution permission cannot be acquired" on the call to
GetStore()
when I am passing my constructed evidence for the previous version of the
assembly. Is this because the previous version of the assembly is not
currently loaded ? - does it have to be loaded to use its 'evidence' ?

Does anyone have any ideas how to solve this general problem of reading
the
Isolated storage of a previous version of the assembly ?

I think perhaps I should use a different method of opening the Isolated
storage in the future - does anyone have an example of how I could obtain
Version _Independant_ isolated storage based just on the simple name of
the
assembly. (I guess I am looking for the opposite of the previous
discussion
here on how to obtain completely version _Dependant_ Isolated storage..)

Thanks for any clues, hints or comments on similar attempts.

John F.


===
// Get the isolated store for this assembly - this is the original way -
but this isolated storage changes when major version changes,

IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly();


// now try to get the isolated storage for the previous version 5.2.2.2
- so we don't lose it when they upgrade.
Byte [] mybytes;
int discarded;

mybytes =
HexEncoding.GetBytes("00240000048000009400000006020000002400005253413100040000010001000948995ae0b97702f4618ab704f5c138ca4ca9dec812590a64584c0244b1e0bbd05f11932199576e47d82bc5ee22ad40ea706348db50f90c49f55b8a11645d0fe748d01e115cbef570453f9d6f43a1655ae6d155f59c70ba6ea9f88f660c7343f25b4b5b7a3ba78893b26c880bc1529f56edc3aaf6ca9bea2ab2e7501fc875be",out
discarded);


System.Security.Permissions.StrongNamePublicKeyBlob mypublickey = new
System.Security.Permissions.StrongNamePublicKeyBlob(mybytes);


System.Security.Policy.StrongName mysn = new
System.Security.Policy.StrongName(
mypublickey,"AccountableSoftwareInc.AnyViewInstall.DatabaseInstall",new
Version(5,2));

System.Security.Policy.Evidence myEvidence = new
System.Security.Policy.Evidence(null,null) ;

myEvidence.AddAssembly(mysn);

// next line throws exception : Execution permission cannot be acquired

//IsolatedStorageFile isf_oldversion =
IsolatedStorageFile.GetStore(IsolatedStorageScope.Assembly,null,null,myEvidence,typeof(System.Security.Policy.StrongName)
);

===
 
Thanks for the Response Luc, I appreciate it.

Those are good ideas - (export and import functionality), and the location
of the physical file where Isolated Storage really is.

My physical file for Assembly and user specific isolated storage, is
here(see below) , but I am not sure how to find it based on those hash
strings - anyone know what they are ? - I think I could just search for my
actual filename (frmDBInstallSettings.xml) which is found there.

C:\Documents and Settings\username.DOMAIN\Local Settings\Application
Data\IsolatedStorage\yqm5hggu.cxj\msxfauad.pz1\StrongName.3wxwevfgvyb3axfxwucczltvww40hw1y\AssemFiles

I would still be interested In any comments about my Code which attempts to
read the Isolated storage of a Previous Major Version Assembly - Does anyone
know if this is possible ? Especially without attempting to load the previous
version assembly...


John F.
 
Back
Top