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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:59:29+00:00 2026-05-22T20:59:29+00:00

I have developed a WCF Service Application hosted in IIS 7.5 targeting .NET 3.5

  • 0

I have developed a WCF Service Application hosted in IIS 7.5 targeting .NET 3.5 configured with only a basicHttpBinding endpoint. The OperationContract signature consists of a Composite type where one of its properties is a custom type. When this property is not initialized by the consuming client, the deserializer on the service appears to ignore the property leaving it null/nothing. I would like to initialize this custom type if it null/nothing and I realize that WCF serialization doesn’t call constructors so I’ve used the deserialization callback. The callback executes and intializes the type but immediately after the callback completes this property returns to null/nothing. Stepping through the code, the ExtensionData property setter executes immediately after the callback and it is at this point where I notice that the property is reset to null/nothing. What am I missing? Here is my sample code

 <DataContract(Name:="Request")> _
Public Class Request
    Implements IExtensibleDataObject

    <DataMember(Name:="MyCustomType")>
    Public MyCustomType As CustomType 

    Private _ExtensionDataObject As ExtensionDataObject

    Public Overridable Property ExtensionData() As ExtensionDataObject Implements IExtensibleDataObject.ExtensionData
        Get
            Return _ExtensionDataObject
        End Get
        Set(value As ExtensionDataObject)
            _ExtensionDataObject = value
        End Set
    End Property


    <OnDeserializing()>
    Sub OnDeserializing(c As StreamingContext)
        Me.myCustomType = New CustomType()
    End Sub

End Class
  • 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-22T20:59:30+00:00Added an answer on May 22, 2026 at 8:59 pm

    If the client didn’t initialize the property, then it’s value is actually Nothing, and the fact that it is null/Nothing will be present in the serialized Request object. So prior to the deserialization happening, your OnDeserializing method is called, and it initializes the variable; but then the deserialization happens, and since there is a value for the property (which happens to be Nothing/null), it will override it.

    I think what you want is to have an OnDeserializ*ed* callback, which will initialize the member after the deserialization happened, if it’s value is Nothing:

    <OnDeserialized()>
    Sub OnDeserialized(ByVal c as StreamingContext)
        If Me.myCustomType Is Nothing Then
            Me.myCustomType = new CustomType()
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed an ASP.NET application that includes a WCF service. This service needs
I have developed a Web service using WCF Service Application. This service application is
I have developed the WCF web service in vb.net in visual studio 2010 express
I have a simple WCF service (hosted as its own site in IIS). It
I have developed a WCF application which is being consumed by three .NET web
I have a windows application that acts as a WCF Service that I developed
I have a WCF service in an ASP.NET AJAX app that is returning json.
I have develope a small web application in that i am using wcf service,I
i have develop a silverlight application with wcf net.tcp binding. i want create an
I have developed a sample WCF REST service that accepts that creates an Order

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.