Hello again,
This seems to be an error in my entire solution and not in
IsolatedStorage. Creating a new project in the solution without adding
any files and setting the newly created project as startup project
triggers the same error. Guess I need to debug some more. Though I got
the storage of a file on the Internal Memory of the phone to work,
just writing a file. Like:
private const string SettingsFile = "settings.xml";
private static string SettingsDir =
Environment.GetFolderPath(Environment.SpecialFolder.Personal);
private T RetrieveSettingFromFile<T>(string dir, string file)
where T : class
{
string fn = System.IO.Path.Combine(dir, file);
if (File.Exists(fn))
{
try
{
using (var stream = File.Open(fn, FileMode.Open,
FileAccess.Read))
{
return
(T)SerializationHelper.DeserializeData<T>(stream);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Could not
retrieve file " + fn + ". With Exception: " + ex.Message);
}
}
return null;
}
private void SaveSettingToFile<T>(string dir, string file, T data)
{
string fn = System.IO.Path.Combine(dir, file);
try
{
if (File.Exists(fn)) File.Delete(fn);
using (var stream = File.Open(fn, FileMode.CreateNew,
FileAccess.Write))
{
SerializationHelper.SerializeData<T>(data, stream);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Could not save
file " + fn + ". With Exception: " + ex.Message);
}
}
public void SetSettings(Settings settings)
{
SaveSettingToFile<Settings>(SettingsDir, SettingsFile, settings);
}
public Settings GetSettings()
{
return RetrieveSettingFromFile<Settings>(SettingsDir, SettingsFile);
}
So that is pretty nice. Could be cool if I could just reuse my
implementation from WP7, but this works fine as well.
On Wed, Sep 28, 2011 at 1:01 PM, Tomasz Cielecki <[email protected]> wrote:
> Hello!
>
> I can't seem to find any information about System.IO.IsolatedStorage
> for MonoDroid apart from the docs, which are not very describing. So I
> just tried out the code I already had running on WP7 and using that on
> MonoDroid. But when compiling it I get the following errors:
>
> "C:\ENM\Dev\WebClient\src\prod\PubWeb\NSPublic.AndroidClient\NSPublic.AndroidClient.csproj"
> (SignAndroidPackage target) (1) ->(_CompileAndroidPackage target) ->
> MANDROID : error : while loading assemblies:
> System.IO.FileNotFoundException: Could not load assembly
> 'System.Windows, Version=2.0.5.0, Culture=neutral,
> PublicKeyToken=7cec85d7bea7798e'. Perhaps it doesn't exist in the Mono
> for Android profile?
> [C:\ENM\Dev\WebClient\src\prod\PubWeb\NSPublic.AndroidClient\NSPublic.AndroidClient.csproj]
> monodroid : error 1: System.NullReferenceException: Object reference
> not set to an instance of an object
> [C:\ENM\Dev\WebClient\src\prod\PubWeb\NSPublic.AndroidClient\NSPublic.AndroidClient.csproj]
>
> So what I guess it is trying to do is that
> System.IO.FileNotFoundException is trying to load System.Windows,
> which is not in MonoDroid. Are there any samples of how to use
> Isolated storage, or should I just write directly to the Internal
> Memory on the phone?
>
> --
> Med Venlig Hilsen / With Best Regards
> Tomasz Cielecki
> http://ostebaronen.dk
>
--
Med Venlig Hilsen / With Best Regards
Tomasz Cielecki
http://ostebaronen.dk
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid