c# - Deserializing from SQL Server Compact throws a "There is an unclosed literal string." error -


i trying store objects in sql server compact (sql ce) database serializing them soap formatter. serializing seems work fine, when try deserialize object error saying

there unclosed literal string. line 53, position 72.

furthermore, after restarting application on attempting fill dataset following error:

failed enable constraints. 1 or more rows contain values violating non-null, unique, or foreign-key constraints.

all columns (except id) allow null values , non-unique, have no idea comes from. here code of serializer:

public static class serializer {     static public string serialize(assessmentreport theobject)     {         memorystream mstream = new memorystream();                     soapformatter formatter = new soapformatter();         formatter.serialize(mstream, theobject);         byte[] buffer = mstream.toarray();         mstream.close();         string value = encoding.utf8.getstring(buffer);         return value;      }      static public assessmentreport deserialize(string value)     {         byte[] buffer = encoding.utf8.getbytes(value);         memorystream mstream = new memorystream(buffer);         soapformatter formatter = new soapformatter();         mstream.position = 0;         assessmentreport thereport = (assessmentreport)formatter.deserialize(mstream);         mstream.close();         return thereport;     } } 

here how call serializer (thereport instance of object serialized):

examtableadapter.updateasmfile(serializer.serialize(thereport), examid); 

and here how calling deserializing method:

string value = convert.tostring(examtableadapter.getasmfile(2)); asmreport thereport = serializer.deserialize(value) 

the field in sql server compact database string saved of type nvarchar limit of 3500.

i tried using binary formatter, when serializing seems return empty byte[] buffer. need deep serializing, that's why xml serializer out of question.

ok 1 have been trying figure out more 2 months now. while not find logical solution problem, seems changing encoding utf7 fixed problem. can't think of reason why issue, seems specific machine (i had opportunity run code on computer , worked utf8).


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -