E
Elder Hyde
For you .NET gurus out there,
Any ideas how isolated storage does its isolation magic? It is quite
smart, it does the things you'd expect it to do. I'm interested in
knowing how they do this!
For instance:
1. If you put your isolated storage code in a dll, it knows that it is
being called from an .exe, so it takes into account the identity of this
calling assembly, and create a unique path for the files accordingly. I
gather we can simulate this using a hash of
Assembly.GetCallingAssembly(). Still no biggie.
2. However, if you put your isolated storage code in a dll, which in
turn is called from another dll, which, again, in turn is called from an
..exe, it also does this correctly. This is still OK, maybe we can use
Assembly.GetEntryAssembly() to get the identity of the .exe.
3. But... in ASP.NET, GetEntryAssembly() returns NULL, so if they had
used it, it wouldn't have worked. Let's say we have a WebApplication,
which calls a function in a DLL, which calls your isolated storage code
in another DLL. How do you get that WebApplication identity?
GetCallingAssembly gives you the second DLL. GetEntryAssembly() returns
null.
After thinking about it, I think they must be doing this recursively.
That is, from your isolated storage code's assembly, trace the callchain
back all the way to the "entry" assembly. So if we have, say, 4 DLLs
called one after another by an .exe, the directory structure will be
something like:
- EXE name (probably hashed)
- DLL1 name
- DLL2 name
- DLL3 name
- DLL4 name
But now I'm getting confused What if, say, there are TWO different
functions containing isolated storage code? One in DLL2, the other in
DLL4? If we go by the scheme I was thinking about, the IsolatedStorage
files location for those two will be different. Which may not be what
one would expect--one would expect that for that one .EXE, every
isolated storage data will be stored in one unique location.
So how do they work this magic out? I've been thinking about it for
hours now
Thanks in advance for any ideas and suggestions!
Elder.
Any ideas how isolated storage does its isolation magic? It is quite
smart, it does the things you'd expect it to do. I'm interested in
knowing how they do this!
For instance:
1. If you put your isolated storage code in a dll, it knows that it is
being called from an .exe, so it takes into account the identity of this
calling assembly, and create a unique path for the files accordingly. I
gather we can simulate this using a hash of
Assembly.GetCallingAssembly(). Still no biggie.
2. However, if you put your isolated storage code in a dll, which in
turn is called from another dll, which, again, in turn is called from an
..exe, it also does this correctly. This is still OK, maybe we can use
Assembly.GetEntryAssembly() to get the identity of the .exe.
3. But... in ASP.NET, GetEntryAssembly() returns NULL, so if they had
used it, it wouldn't have worked. Let's say we have a WebApplication,
which calls a function in a DLL, which calls your isolated storage code
in another DLL. How do you get that WebApplication identity?
GetCallingAssembly gives you the second DLL. GetEntryAssembly() returns
null.
After thinking about it, I think they must be doing this recursively.
That is, from your isolated storage code's assembly, trace the callchain
back all the way to the "entry" assembly. So if we have, say, 4 DLLs
called one after another by an .exe, the directory structure will be
something like:
- EXE name (probably hashed)
- DLL1 name
- DLL2 name
- DLL3 name
- DLL4 name
But now I'm getting confused What if, say, there are TWO different
functions containing isolated storage code? One in DLL2, the other in
DLL4? If we go by the scheme I was thinking about, the IsolatedStorage
files location for those two will be different. Which may not be what
one would expect--one would expect that for that one .EXE, every
isolated storage data will be stored in one unique location.
So how do they work this magic out? I've been thinking about it for
hours now
Thanks in advance for any ideas and suggestions!
Elder.