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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:20:10+00:00 2026-06-13T21:20:10+00:00

Trying to pass complex class type that contains primitive types with interfaces and lists

  • 0

Trying to pass “complex” class type that contains primitive types with interfaces and lists of interfaces/classes.

I guess the problematic member is:

public List<IMyInterface> IntrfList

Runtime Error:

An error occurred while receiving the HTTP response to http:/localhost/xxxxxx/xxxxxService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

The descriptive error from MS Service Trace Viewer (SvcTraceViewer):

Type ‘myType’ cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types.

I did as the explanation suggests but didn’t help.

The “shared” class:

[System.Runtime.Serialization.DataContract]
    public class ServerState
    {
        private Queue<IJob> _mWaitingQueue;
        public Queue<IJob> mWaitingQueue
        {
            get
            {
                lock (_LockObjWaiting)
                {
                    return _mWaitingQueue;
                }
            }
            private set
            {
                _mWaitingQueue = value;
            }
        }
        private object _LockObjWaiting = new object();

        private List<IJob> _mInPrograssList = new List<IJob>();

        [DataMember]
        public List<IJob> mInPrograssList
        {
            get
            {
                    return _mInPrograssList;
            }
            private set
            {
                _mInPrograssList = value;
            }
        }
}

IJob is an interface.
The structure of IJob is like this:

IJob (Interface)
  - JobBase (Abstract class)
    - JobA (Driven from JobBase)
    - JobB (Driven from JobBase)
  • 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-13T21:20:12+00:00Added an answer on June 13, 2026 at 9:20 pm

    Alright, got it!

    I posted the solution in my blog: http://livshitz.wordpress.com/2012/11/06/wcf-serialization-datacontract-runtime-error-type-mytype-cannot-be-serialized/

    After fighting and cutting all possible parts of that “shared” class, I got to the problematic area.

    The problem was that I used interface as a member (or list of..), which associated with Driven classes.

    And that’s it! The serializer having problem figuring out how to serialize that member, so here is the solution:

    When using interface as a member (or list of interface) in a class that is about to be serialized and shared via WCF, the Shared class must specify the possible types of the interface by adding to it:

    [System.Runtime.Serialization.KnownType(typeof(JobA))]
    [System.Runtime.Serialization.KnownType(typeof(JobB))]
    

    And each of those types must be marked with:

    [System.Runtime.Serialization.DataContract]
    

    Note: Since JobBase is abstract, no reason to mark it with KnownType…

    That’s it.

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

Sidebar

Related Questions

I'm trying to pass a complex object (that can be serialized, if that helps)
I am trying pass class as value in hashmap. I need to get the
I'm trying to make a class that uses the Levenshtein distance function to compare
I am trying to find the best way to pass complex configurations in a
I am getting some weird results while trying to pass a complex JSON object
I'm trying to pass an array out of a class into my main program
I'm trying to pass a complex object via Windows Communication Foundation, but I get
I'm trying to pass Vector of complex objects as a result of a WS
I don't need anything fancy or complex, I'm just trying to pass a simple
I am trying to make a reusable UI class. I admit that I don't

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.