다음을 통해 공유


Isolation by User, Domain, and Assembly

If an application uses a third-party assembly that requires a private data store, isolated storage can be used to store the private data. Isolation by user, domain, and assembly ensures that only code in a given assembly can access the data, and only when the assembly is used by the application that was running when the assembly created the store, and only when the user for whom the store was created runs the application. Isolation by user, domain, and assembly keeps the third-party assembly from leaking data to other applications. This isolation type should be your default choice if you know that you want to use isolated storage but are not sure which type of isolation to use. Calling the static GetStore method of IsolatedStorageFile and passing in a user, domain, and assembly, IsolatedStorageScope returns storage with this kind of isolation.

The following code example retrieves a store isolated by user, domain, and assembly. The store can be accessed through the isoFile object.

Dim isoStore As IsolatedStorageFile
isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or IsolatedStorageScope.Assembly Or IsolatedStorageScope.Domain, Nothing, Nothing)
[C#]
IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null);

Another method is available as a shortcut, as shown in the following code example. This shortcut cannot be used to open stores capable of roaming; use GetStore in such cases.

Dim isoStore As IsolatedStorageFile
isoStore = IsolatedStorageFile.GetUserStoreForDomain()
[C#]
IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForDomain();

See Also

Types of Isolation | Isolation by User and Assembly | Performing Isolated Storage Tasks