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
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 :-)
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