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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:36:45+00:00 2026-05-21T22:36:45+00:00

I created a WCF service.in my data contract I have two attributes lets say:

  • 0

I created a WCF service.in my data contract I have two attributes lets say:

[DataMember]
Private User objUser;

and

[DataMember]
Private tempClass ObjTemp;

I have get and set property for both the attributes. In my implementation class, I have an object of datacontract class… lets say. objData.

When I assign

objData.ObjTemp=(function which return objTemp);

the service work fine. But, when I assign.

objData.objUser=(function which return objUser)

it throws following error:

The underlying connection was closed: The connection was closed
unexpectedly.

When I comment

objData.objUser=(function which return objUser)

it works fine again.

When I inspect the code inside my User class, I found one property creating problem. When I change the property that property it works fine too; but i do not know why that property is creating problem.

The property is like this:

public IPAddress IP { get; set; }

Now this IPAdress class contains a constructor, and get and set for ip variable. In the get, it simply returns ip variable.

in set it checks some condition and then assign value to ip variable. If condition fails, it throws an exception. Can anybody explain what the problem could be?

I just checked another thing.

If i remove [DataMember] attribute from private User objUser; it works fine; but if i put [DataMember] back it generates the same error.

any suggestions?

  • 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-21T22:36:46+00:00Added an answer on May 21, 2026 at 10:36 pm

    You will most likely find that objUser is not serializable. For more info read this: MSDN: Using Data Contracts

    To quote a short snippet of that:

    All .NET Framework primitive types, such as integers and strings, as well as certain types treated as primitives, such as DateTime and XmlElement, can be serialized with no other preparation and are considered as having default data contracts…. New complex types that you create must have a data contract defined for them to be serializable.

    You could also consider using the Service Trace Viewer tool from Microsoft to help track down the exact problem you are having.

    Edit:

    if it is the System.Net.IPAddress object you are talking about, then it is marked as [Serializable], but it doesn’t have a default parameterless constructor, which is one of the requirements necessary when using the DataContractSerializer (which is what is used to serialize your data objects over the WCF boundary). You may also want to ensure that if any of your custom objects used in your WCF calls contain any further custom objects (in properties, like your IPAddress) then they are decorated with the KnownType attribute.

    So, as a solution you can either write your own IPAddress class that plays nice with the DataContractSerializer, or switch to using the XmlSerializer in your WCF calls.

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

Sidebar

Related Questions

I have created a simple wcf service which used the WCF Service Library template.
I have created a basic WCF service in IIS. I am aware that this
I have created a reference to an IIS hosted WCF service in my ASP.NET
I created a WCF service library project in my solution, and have service references
I am trying to create a WCF Streaming Service. I have two requirements that
I have created a WCF service in my project and I have some classes
I created a wcf service based on ServiceHostFactory, and i'm hosting it in IIS6.
I've created a WCF service and when I browse to the endpoint I get
I’ve just created a WCF service/client and it all works fine when running on
I've created a .NET WCF service that is intended to always be over HTTPS.

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.