none
Self Paced Training Kit 70-536 -> IsolatedStorage RRS feed

  • Question

  • Hi,

      I have posted this question here: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/54479bf3-be78-4806-841e-a63523c4f448 and based on a suggestion from one of the replies I'm going to ask the question here as well.

    In the Self Paced Training Kit for exam 70-536 on page 92 there is a question:

      You need to store data to isolated storage in such a way that other applications that are run by the same user and other users running the same application cannot access the data directly.  Which method should you call to create the IsolatedStorageFile object?

    A.  IsolatedStorageFile.GetUserStoreForAssembly()

    B.  IsolatedStorageFile.GetMachineStoreForAssembly()

    C.  IsolatedStorageFile.GetUserStoreForDomain()

    D.  IsolatedStorageFIle.GetMachineStoreForDomain()

    The answer to the question is listed as A because the book states that it is private to the user and assembly and that it is NOT answer C because the store could be accessed by other assemblies running in the same application domain.

    This confused me, I thought it was C because in the msdn documentation GetUserStoreForDomain() is equivalent to: 

    GetStore(IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain | IsolatedStorageScope.User, null, null);

    And looking at this it would seem that the store would not be able to be accessed by other assemblies running in the same application domain.

    Also the documentation states: Different assemblies running within the same application domain always have distinct isolated stores.

    I was wondering if someone could provide me with a better explanation then the book as given.  

    Thanks, Matt


    Friday, March 2, 2012 6:47 PM

Answers

  • Hi,

    sorry, have to completly edit my reply - I made a mistake with the site ... I was thinking a little bit about my answer and decided to read up everything again ...

    Application Domain Identity is different for each ApplicationDomain that is created. So one Application called two times has different Application Domains.

    So your Answer C has the problem, that the files you write ca only be accessed as long as you do not stop and start the application again.

    So the question is not concrete enough: It is not said, that the application always want to access the files. I think this is something they simply asumed.

    Konrad

    Friday, March 2, 2012 8:36 PM
    Answerer

All replies

  • Hi,

    sorry, have to completly edit my reply - I made a mistake with the site ... I was thinking a little bit about my answer and decided to read up everything again ...

    Application Domain Identity is different for each ApplicationDomain that is created. So one Application called two times has different Application Domains.

    So your Answer C has the problem, that the files you write ca only be accessed as long as you do not stop and start the application again.

    So the question is not concrete enough: It is not said, that the application always want to access the files. I think this is something they simply asumed.

    Konrad

    Friday, March 2, 2012 8:36 PM
    Answerer
  • Thank you for the reply.  So each time I run an application that uses GetUserStoreForDomain() it would use a different store?

    Because if I run this test app it accesses the same file each time:

                IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForDomain();

                IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("morse", FileMode.Append, FileAccess.Write, isoFile);
                StreamWriter writer = new StreamWriter(isoStream);
                writer.WriteLine("This is a test at: " + DateTime.Now);

                writer.Close();
                isoFile.Dispose();
                isoFile.Close();

    This creates a file "morse" located at: ...\AppData\Local\IsolatedStorage\tmambwkq.gs2\hbrrmhtu.3gi\Url.4gerx3xeiwbnv5y4pc3mpfu2t3za5202\Url.4gerx3xeiwbnv5y4pc3mpfu2t3za5202\Files\

    And appends a line to it each time I run the application.  Please correct me if I'm wrong but I just want to fully understand, if what you were saying was true, wouldn't it create a new file under a new folder structure?

    Saturday, March 3, 2012 2:43 AM
  • Experience from reading "practice questions" and other training materials, including not only the self-paced training kits but also other sources, indicates that they usually contain some mistakes and you cannot trust everything that they say.

    In your specific case, answer C as explained in the training kit conflicts with the msdn documentation. Who is right? I don't know right away, but you could always test it in the same way as you wrote a piece of code to verify whether the answer that Konrad gave you was correct.

    You can try out the various combinations of assemblies and domains by writing a small console application that uses AppDomain.CreateDomain and then invokes methods from the same assebly on the new AppDomain (for testing same-assembly, different-domain) and also referencing a DLL and invoking a method in the DLL for testing same-domain, different-assembly.

    Saturday, March 3, 2012 7:07 AM