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 6214689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:55:19+00:00 2026-05-24T06:55:19+00:00

We have a huge application with a lot of classes. We are currently porting

  • 0

We have a huge application with a lot of classes. We are currently porting this .net application to IPad with Monotouch. We have some problems with the DataContractSerializer and we would like to use Marc Gravell’s protobuf-net serializer.

The communication between the client and the server is managed by a WCF Service.

A WCF service is made of one Interface exposed to the client and the server, and one implementation of this interface on the server.

The interface looks like that:

[ServiceContract]
public interface IMyService
{
    [OperationContract]
    SomeObject MyFunction(SomeObject myObject);
}

The server side implementation looks like that:

[ServiceBehavior(...)]
public class MyService
{
    public SomeObject MyFunction(SomeObject myObject)
    {
    }
}

Our classes looks like that:

[DataContract]
public class MyClass
{
    [DataMember]
    public int SomeProp {get; set;}

    [OnSerialized]
    public void OnSerialized(StreamingContext context)
    {
    }
}

So here are my questions:

  • What would be the changes to do to my classes, wcf interface and wcf implementation.

  • How would I replace the default WCF DataContractSerializer to the Protobuf Serializer.

Please note that on monotouch, I only have access to Protobuf and Protobuf.Meta namespaces.

[EDIT]
I found a way to swap the serializer runtime:
Custom WCF DataContractSerializer

The above solution uses the DataContractSerializerOperationBehavior. Does Protobuf-net provides such behavior?

  • 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-24T06:55:20+00:00Added an answer on May 24, 2026 at 6:55 am

    In all honesty, I am unfamiliar with the WCF options available to you in monmotouch; they are very different between regular .NET and Silvelight, for example – and I see no reason to assume that monotouch has the ability to swap serializer at runtime (which “full” .NET does, at least under the MS version). This makes it hard to do the transition silently, as we can’t wrestle control from DataContractSerializer.

    As such, IMO the simplest option is to seize control of the data manually, and send raw byte[] – ideally with MTOM encoding enabled if monotouch can do that. Then once you have your byte[] the world is your mollusc, as they say.

    Re changes to your types… well, MyFunction() is an oddity, in that it doesn’t transfer any data, so I’m not sure what you want me to suggest on that one. With MyClass, all it needs is a unique number (unique within the type, not globally) per member, i.e.

    [DataContract]
    public class MyClass
    {
        [DataMember(Order=1)] // <==== this provides the 1 as the key
        public int SomeProp {get; set;}
    
        // see below re callback
    }
    

    You also have a serialization callback; these are fully supported, but it expects to find a familiar pattern – StreamContext is not one that I know of (although it should work with StreamingContext and a few others).

    Finally, note that by default protobuf-net executes the constructor, which is different to DataContractSerializer. If you desire, you can suppress this via:

    [DataContract(SkipConstructor=true)]
    public class MyClass {...}
    

    If I’ve missed the intent here, let me know.

    Note there are also ways of doing all the configuration without changing/adding any attributes if you prefer.

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

Sidebar

Related Questions

We currently have a quite complex business application that contains a huge lot of
I have a huge application and at some point, when a redirect is involved
We have this huge application that has 18 projects in our source control (
i have to modify an asp.net application. The app consists of an huge gridview
We currently have a Live ASP.NET application (Basically a CMS) running on our IIS7
I have a problem with an application I'm currently developing. In this program I
I have a huge application running in glassfish server which creates lot of short-living
I have quite a huge WPF application with a lot of XAML files. Every
I have TTS application with a huge raw resource (a lot of wav file
Currently, I have to fix an existing Silverlight application that's leaking a lot of

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.