Используйте IsolatedStorageFile.GetUserStoreForAssembly
для создания изолированного хранилища из библиотеки.
Подробности здесь
Вы можете использовать приведенный ниже тип в своей библиотеке. И application1 и application2 могут записывать / читать в / из того же изолированного хранилища с помощью указанного ниже типа в вашей библиотеке.
ниже:
public class UserSettingsManager
{
private IsolatedStorageFile isolatedStorage;
private readonly String applicationDirectory;
private readonly String settingsFilePath;
public UserSettingsManager()
{
this.isolatedStorage = IsolatedStorageFile.GetMachineStoreForAssembly();
this.applicationDirectory = "UserSettingsDirectory";
this.settingsFilePath = String.Format("{0}\\settings.xml", this.applicationDirectory);
}
public Boolean WriteSettingsData(String content)
{
if (this.isolatedStorage == null)
{
return false;
}
if (! this.isolatedStorage.DirectoryExists(this.applicationDirectory))
{
this.isolatedStorage.CreateDirectory(this.applicationDirectory);
}
using (IsolatedStorageFileStream fileStream =
this.isolatedStorage.OpenFile(this.settingsFilePath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write))
using (StreamWriter streamWriter = new StreamWriter(fileStream))
{
streamWriter.Write(content);
}
return true;
}
public String GetSettingsData()
{
if (this.isolatedStorage == null)
{
return String.Empty;
}
using(IsolatedStorageFileStream fileStream =
this.isolatedStorage.OpenFile(this.settingsFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
using(StreamReader streamReader = new StreamReader(fileStream))
{
return streamReader.ReadToEnd();
}
}
}
EDIT:
DLL должна быть сборкой со строгим именем. На снимках ниже показано, как добавить строгое имя в сборку.
![Go to Project properties](https://i.stack.imgur.com/jXoYB.png)
![In the Signing tab of the properties, Click on](https://i.stack.imgur.com/Hslkr.png)