Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4000338
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:46:09+00:00 2026-05-20T07:46:09+00:00

I am trying to store some objects in an SQL Server Compact (SQL CE)

  • 0

I am trying to store some objects in an SQL Server Compact (SQL CE) database by serializing them with a SOAP formatter. Serializing seems to work just fine, but when I try to deserialize the object I get an error saying

There is an unclosed literal string. Line 53, position 72.

Furthermore, after restarting the application on attempting to fill the dataset I get the following error:

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

All my columns (except the ID) allow for null values and are non-unique, so I have no idea where this comes from. Here is the code of my 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 is how I call the serializer (theReport is an instance of the object to be serialized):

examTableAdapter.UpdateAsmFile(Serializer.Serialize(theReport), examID);

And here is how I am calling the deserializing method:

string value = Convert.ToString(examTableAdapter.GetAsmFile(2));
AsmReport theReport = Serializer.Deserialize(value)

The field in the SQL Server Compact database where the string is saved is of type nvarchar with a limit of 3500.

I tried using a binary formatter, but when serializing it seems to always return an empty byte[] buffer. I really need deep serializing, that’s why the XML serializer is out of question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:46:10+00:00Added an answer on May 20, 2026 at 7:46 am

    Ok so this one I have been trying to figure out for more than two months now.
    While I could not find a logical solution to the problem, it seems that changing the encoding to utf7 fixed the problem. I can’t think of a reason why this would be the issue, but it seems to be specific to my machine (I finally had the opportunity to run the code on another computer and it worked perfectly with utf8).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a database to store some questions and answers for
I'm trying to save some specific JSon data and store them in a simple
I'm working in a client's SQL Server 2005 database and I'm seeing some odd
I'm trying to store some metadata in a .txt file using xattr on a
I'm trying to store some binary data obtained from read() in my buffer using
I am trying to store some soundclips which are tagged with Images chosen from
I am trying to store some integers in a file and I am storing
I'm trying to create a 2D array to store some values that don't change
I am trying to extract some part of string and store it to hbase
I am playing with the SqlFileStream to store my (large) objects on a SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.