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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:34:45+00:00 2026-06-01T10:34:45+00:00

I have the following problem, given the following service contract, data contract, and service

  • 0

I have the following problem, given the following service contract, data contract, and service implementation, how should I get WCF to serialize my object graph without stack overflowing?

Service Contract:

[ServiceContract]
public interface IService1
{
    [OperationContract]
    TestObjectA CircularSerializationTest();
}

Data Contracts

[DataContract(IsReference = true)]
public class TestObjectA
{
    [DataMember]
    public TestObjectB B { get; set; }
}

[DataContract(IsReference = true)]
public class TestObjectB
{
    [DataMember]
    public TestObjectC C { get; set; }
}

[DataContract(IsReference = true)]
public class TestObjectC
{
    [DataMember]
    public TestObjectA A { get; set; }
}

Service Implementation:

public class Service1 : IService1
{
    public TestObjectA CircularSerializationTest()
    {
        var a = new TestObjectA();
        var b = new TestObjectB();
        var c = new TestObjectC();

        a.B = b;
        b.C = c;
        c.A = a;

        return a;
    }
}

Why is this question unique? First, every other example I’ve been able to find uses a tree of objects, or it uses circular references between two objects. In the instance of a tree (Grandparent => Parent => Child) the relationship isn’t actually circular, but objects are used between different nodes. Or, in the second case, either the same object is circular (Person has a list of employees that are also persons, this is in one of the example I found on the MSDN) or its a parent => child => parent relationship which is circular, but not quite extensive enough.

Also, in my case, its not possible to ‘flatten’ the objects into a tree, they need to maintain the same object references.

Thanks in advance to any advice or insight into this problem.

  • 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-01T10:34:46+00:00Added an answer on June 1, 2026 at 10:34 am

    I figured it out.

    It seems the stack overflow isn’t actually occurring in WCF at all, it’s actually happening in the WCF test client. I think Visual Studio must connect to it because when it crashes, it blows up inside of visual studio which is why I thought it was a problem with the service. The test client displays the result as a tree, and my guess is that they didn’t anticipate that the result could be a cyclic object graph, thus the stack overflow.

    Lesson Learned: Don’t use the WCF test client. Use a console app.

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

Sidebar

Related Questions

I have the following problem: I am given a tree with N apples, for
I have a problem with nested templates and their template specialization. Given the following
I have following problem: I have built a tabbar application with 4 tabs. I
I have following problem, Code: String a=Yeahh, I have no a idea what's happening
I have the following problem: I have a form in site/banen (currently local running
I have the following problem. I have three classes, A, B and C. A
I have the following problem: I implemented a managed mobile application for Windows Mobile
I have the following problem that the standard library doesn't solve well, and I'm
I have the following problem: I got a view with two text fields and
I have the following SQL problem. Scenario: I have two tables: Change and ChangeTicket.

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.