IsolatedStorageFileStream access problem

Hiall

I am implementing a class library (Addin ) in VB 2005 for Solidworks 2006 3D cad tool. I wanted to use IsolatedStorageFile for my persistant storage.

I used my code like this

PrivateFunction CreateSettingsStream(ByVal keyAsString)As IsolatedStorageFileStream

Dim storeAs IsolatedStorageFile = IsolatedStorageFile.GetMachineStoreForDomain()

ReturnNew IsolatedStorageFileStream(("abc.txt"), FileMode.Create, store)

EndFunction

When I run the Addin I get a strange error in the following statement

Dim storeAs IsolatedStorageFile = IsolatedStorageFile.GetMachineStoreForDomain()

and the error is"Unable to determine the identity of domain."

Any body knows how to avoid this error.

/Thanks in advance

Prash

[2129 byte] By [Prashweenet] at [2007-12-28]
# 1
I also encountered the same problem. I also tried to access the IsolatedStorage from an AddIn and got and IsolatedStorageExceptions saying "Unable to determine the identity of a domain". In normal windows applications I could easily use the IsolatedStorage but in AddIns only I get this error. Do anyone know a solution or a work around for this problem

Thanks

/Kumudu

KumuduG at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Hi

The workaround I got here is

Dim store As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForAssembly()

Return New IsolatedStorageFileStream(GetSettingsFileName(key), FileMode.Create, store)

Check this is working for you?

But for orginal problem I am still stuck

/Prash

Prashweenet at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

Prashweenet,

Based on your description, I guess your problem is IsolatedStorage Exception. IsolatedStorageException uses the ISS_E_ISOSTORE, which has the value 0x80131450.

The most common examples of isolated storage exceptions are as follows.

Missing evidence. Isolated storage requires evidence (information about the assembly and its origin) in order to determine the identity of the code and connect it to the correct associated file space. Without this information, isolated storage cannot be used.

Invalid operations. Some FileStream operations are not supported for isolated storage.

Furthermore, please pay more attention of the GetMachineStoreForDomain method. Here I give you an example on this method:

Dim isoFile As IsolatedStorageFile

isoFile = IsolatedStorageFile.GetUserStoreForDomain()

' Open or create a writable file.

Dim isoStream As New IsolatedStorageFileStream(Me.userName, FileMode.OpenOrCreate, _

FileAccess.Write, isoFile)

Dim writer As New StreamWriter(isoStream)

writer.WriteLine(Me.NewsUrl)

writer.WriteLine(Me.SportsUrl)

' Calculate the amount of space used to record the user's preferences.

Dim d As Double = Convert.ToDouble(isoFile.CurrentSize) / Convert.ToDouble(isoFile.MaximumSize)

Console.WriteLine(("CurrentSize = " & isoFile.CurrentSize.ToString()))

Console.WriteLine(("MaximumSize = " & isoFile.MaximumSize.ToString()))

' StreamWriter.Close implicitly closes isoStream.

writer.Close()

isoFile.Dispose()

isoFile.Close()

Return d

The code example is from msdn as linked: http://msdn2.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.getmachinestorefordomain.aspx

Hope that can help you :-)

BrunoYu-MSFT at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4

Hi again

Thanks for the reply.

I still get the error when I execute this line

isoFile = IsolatedStorageFile.GetUserStoreForDomain()

It raises the same error.

Any suggestions?

/Prash

Prashweenet at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5

Prashweenet,

GetUserStoreForDomain will return an IsolatedStorageFile object without a quota if the application domain in which the assembly is installed does not have IsolatedStorageFilePermission. Later attempts to create an IsolatedStorageFile object using the IsolatedStorageFile object that does not have a quota will fail with an IsolatedStorageException.

Please check the assembly that whether it has IsolatedStorageFilePermission. Please take a look at the IsolatedStorageFilePermission class that specifies the allowed usage of a private virtual file systemas follows:

http://msdn2.microsoft.com/en-us/library/system.security.permissions.isolatedstoragefilepermission(VS.71).aspx

BrunoYu-MSFT at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...