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

  • Home
  • SEARCH
  • 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 8827595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:24:34+00:00 2026-06-14T07:24:34+00:00

Tested out the same code in Visual Studio on Windows to make sure. Using

  • 0

Tested out the same code in Visual Studio on Windows to make sure.

Using MonoDevelop on Mac with Mono framework 3.0.1. I’m trying to serialize objects to JSON and need to populate some properties in the OnSerializing event by assigning System.Runtime.Serialization.OnSerializingAttribute to a method. However, mono framework does not appear to be calling into the method. None of the other serialization events work either. Simplified the code for example:

using System;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Runtime.Serialization;

namespace MyApp
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Cereal specialK = new Cereal();

            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Cereal));

            specialK.TheValue="This is a what?";

            MemoryStream stm = new MemoryStream();
            ser.WriteObject(stm, specialK);
            string json = System.Text.Encoding.UTF8.GetString(stm.ToArray());

            Console.WriteLine(json);
            Console.ReadLine();

        }
    }

    [DataContract]
    class Cereal
    {
        [DataMember(Name="set_on_serialize")]
        private string _setOnSerialize = string.Empty;

        public Cereal() { }

        [DataMember(Name = "out_value")]
        public string TheValue
        {
            get;
            set;
        }

        [OnSerializing]
        void OnSerializing(StreamingContext content)
        {
            this._setOnSerialize = "A brick!";
        }
    }
}

In Visual Studio, the output is:
{“out_value”:”This is a what?”,”set_on_serialize”:”A brick!”}

In MonoDevelop on Mac, I get:
{“out_value”:”This is a what?”,”set_on_serialize”:””}

Mono is not calling the OnSerializing event for some reason.

Has anyone else encountered this or can you help explain why the code fails?

Thanks

  • 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-06-14T07:24:35+00:00Added an answer on June 14, 2026 at 7:24 am

    This was a bug in Mono, I just fixed this for you 🙂

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

Sidebar

Related Questions

I'm making a game in OpenGL on Windows using Code::Blocks (C++) and MinGW. All
I tested SOAP method in samsung galaxy tab and is working fine. same code
I am currently trying to write an application that runs the same code exactly
I tested out the script below in jsfiddle and it works fine, can someone
I have tested out hundreds of different codes, either they work and screw something
So, I tested my game out for the first time with the Monkey test.
Tested app in Instrumens for memory leak getting multiple leaks for using multiple times
I tested the following code in firefox scratchpad and got interesting result? var date=new
I tested this on both .Net 4.0 and .Net 4.0 CP, same result. This
Trying to build a marquee control with smooth text animation. Current efforts include: Using

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.