BinaryFormatter Alternatives with limitied security priviledges

  • Thread starter Thread starter Phil Jones
  • Start date Start date
P

Phil Jones

I want to write class that effectively caches object state between instances
of a WindowsForms application running.



The obvious device to use is the [BinaryFormatter] within the
Runtime.Serialization namespace.



However, I would also like the class to be operable within a
No-Touch-Deployment instance, which means I want to work within the
IsolatedStorage container, and within the "Internet Zone" I'm not allowed to
use the [BinaryFormatter] because of the limited permission set.



Is there another way to save and restore the an object instance that is
usable within a limited security context?



Thanks anyone?
 
Cheers,

I've read up on it, and basically the formatter throws an exception at
construction if it doesn't have enough priveledges. Just 'aint no way to
do' binary with out the security pass.

Thanks...
 
Here's some code:


REM -- Setup initial conditions.
Dim myThingToStore As New ArrayList
myThingToStore.Add("My Name")

REM -- Get the isolated storage file.
Dim fileName As String = "WebStorage.bin"
Dim isoStore As IsolatedStorageFile
Dim oFile As New IsolatedStorageFileStream( _
fileName, FileMode.Create, isoStore)

REM -- Serialize the stream.
Dim oFormatter As New Formatters.Binary.BinaryFormatter
oFormatter.Serialize(oFile, myThingToStore)
oFile.Close()


This will work if executed from the local machine, but will fail at the
"Serialize" call if run from the Internet ("Low" security priveledge).

Basically I want to cache object state between instances of a Forms app that
is executing within the "NTD" model (hence the need to use IsolatedStorage).

Any ideas for a work around? Thanks....
 
Back
Top