c# - Isolated Storage not working on windows phone app -
i have isolated storage function write storage :
public static void writeisolatedstorage(object objecttostore, storagetype key) { using (var storage = system.io.isolatedstorage.isolatedstoragefile.getuserstoreforapplication()) using (var storagefile = storage.createfile(key.tostring())) { var xmlserializer = new system.xml.serialization.xmlserializer(typeof(string)); switch (key) { case storagetype.usercredentials: xmlserializer = new system.xml.serialization.xmlserializer(typeof(dmwfusercredentials)); break; case storagetype.backgroundagentusercredentials: xmlserializer = new system.xml.serialization.xmlserializer(typeof(dmwfusercredentials)); break; case storagetype.userprofile: xmlserializer = new system.xml.serialization.xmlserializer(typeof(dmwfuser)); break; case storagetype.inboxitems: xmlserializer = new system.xml.serialization.xmlserializer(typeof(observablecollection<dmwfinboxitem>)); break; case storagetype.inboxtileitems: xmlserializer = new system.xml.serialization.xmlserializer(typeof(observablecollection<dminboxtileinfo>)); break; case storagetype.documentheaders: xmlserializer = new system.xml.serialization.xmlserializer(typeof(observablecollection<dmwfdocumentheader>)); break; case storagetype.searchcache: xmlserializer = new system.xml.serialization.xmlserializer(typeof(list<list<dmwfdocumentheader>>)); break; case storagetype.facebookprofile: xmlserializer = new system.xml.serialization.xmlserializer(typeof(dmfbuserprofile)); break; case storagetype.baseurl: xmlserializer = new system.xml.serialization.xmlserializer(typeof(dmwfurlsetting)); break; default: break; } xmlserializer.serialize(storagefile, objecttostore); } }
and here function storage :
public static dmwfurlsetting getbaseurl(storagetype key) { try { using (var storage = system.io.isolatedstorage.isolatedstoragefile.getuserstoreforapplication()) { using (var storagefile = storage.openfile(key.tostring(), system.io.filemode.open, system.io.fileaccess.readwrite)) { dmwfurlsetting result = new dmwfurlsetting(); var xmlserializer = new system.xml.serialization.xmlserializer(typeof(dmwfurlsetting)); return (dmwfurlsetting)xmlserializer.deserialize(storagefile); } } } catch (exception) { return null; } }
okay , here how call these methods fromm front end , viemodel, using mvvm fr phone app. frontend call :
public string url = (workflowbase.baseurl != null ? workflowbase.baseurl.tostring() : "");
here public property in backend :
public static string baseurl = acctech.wp8.helpers.isolatedstorage.getbaseurl(helpers.isolatedstorage.storagetype.baseurl).baseurl.tostring();
okay here comes weird part, know when start emulator after being closed isolated storage(cache) clean if function called null return... can see in frontend call made inline if if null value, make "". here error when run. ps: if make url static app works
okay , here error when try step through whole process :
i physically unable working have tried google offers... nothing happens , if can please give me answer delighted.
if need more data or info please let me know
workflowbase.baseurl != null , workflowbase class pointing never changed public variable data got why error occoured! .
so yeah noob mistake of week! :p
Comments
Post a Comment