Reputation: 9305
I have a solution that has a MVC-project and a windows console application. Both projects share the same Backend-Project, that loads and saves data.
I need to exchange the data from these two projects. Therefore I decided to use Isolated scope:
private string LoadInstallationFile()
{
IsolatedStorageFile isoStore = IsolatedStorageFile.GetMachineStoreForDomain();
if (!isoStore.FileExists(ClientSettingsFile)) return null;
/* do stuff */
}
private void SaveInstallationFile() {
IsolatedStorageFile isoStore = IsolatedStorageFile.GetMachineStoreForDomain();
using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(ClientSettingsFile, FileMode.CreateNew, isoStore))
{
using (StreamWriter writer = new StreamWriter(isoStream))
{
writer.WriteLine(data);
}
}
}
Now Inside the mvc-project I save the Data using "SaveInstallationFile()". I can access that file from within that mvc-project.
But when I try to access the data using the other (console-)project, the File does not exist.
How can I exchange data between these two? (There is a big chance that both run under different user credentials, so GetUserStore...() IMHO would not work.
Both, the MVC-Application AND the Console-Application run on the Same Server.
Upvotes: 0
Views: 110
Reputation: 5248
If you really need to use isolated storage API you can use GetMachineStoreForAssembly
(if this code is shared in the same assembly for both projects). Currently you use different storages for different applications. But to be honest, I would prefer to use database or custom configurable shared disk path as it looks more flexible solution.
GetMachineStoreForAssembly
is less restrictive version of GetMachineStoreForDomain
(both of them require code to be in the same assembly but GetMachineStoreForDomain
requires it to be also in the same application). You can check MSDN documentation:
GetMachineStoreForAssembly
) is equivalent of GetStore(IsolatedStorageScope.Assembly |
IsolatedStorageScope.Machine, null, null)
GetStore(IsolatedStorageScope.Assembly |
IsolatedStorageScope.Domain | IsolatedStorageScope.Machine,
null, null);
(so, it includes one additional flag that's why it's more restrictive)And also both of them check calling assembly. Not root executing assembly.
Upvotes: 1