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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:21:18+00:00 2026-05-22T21:21:18+00:00

I have a WCF service in place. Normal operation would see the server doing

  • 0

I have a WCF service in place.

Normal operation would see the server doing some processing the returning a populated XactTaskIn object to the client via a callback. I have this working ok.

My problem is that when I try and set the returnData variable to a populated XactException and try to send the XactTaskIn back to the client via the callback, I get the following exception thrown.

Exception – “Type ‘XactException’ with
data contract name
‘XactException:http://schemas.datacontract.org/2004/07/’
is not expected. Consider using a
DataContractResolver or add any types
not known statically to the list of
known types – for example, by using
the KnownTypeAttribute attribute or by
adding them to the list of known types
passed to DataContractSerializer.”
(System.Runtime.Serialization.SerializationException) Exception
Message = “Type ‘XactException’ with
data contract name
‘XactException:http://schemas.datacontract.org/2004/07/’
is not expected. Consider using a
DataContractResolver or add any types
not known statically to the list of
known types – for example, by using
the KnownTypeAttribute attribute or by
adding them to the list of known types
passed to DataContractSerializer.”,
Exception Type =
“System.Runtime.Serialization.SerializationException”

Here is the XactTaskIn class

[DataContract]
public class XactTaskIn
{
    [DataMember]
    public DateTime timeOut;
    [DataMember]
    public DateTime timeIn;
    [DataMember]
    public string name;
    [DataMember]
    public string responseTo;
    [DataMember]
    public String moduleFromName;
    [DataMember]
    public String moduleFromType;
    [DataMember]
    public String methodFromName;
    [DataMember]
    public object[] originalInputs;
    [DataMember]
    public String returnMethodToCall;
    [DataMember]
    public String returnModuleToCall;
    [DataMember]
    public object returnData;

    public XactTaskIn(DateTime timeOut, DateTime timeIn, string name, string responseTo, String moduleFromName, String moduleFromType, String methodFromName, object[] originalInputs, String returnMethodToCall, String returnModuleToCall, object returnData)
    {
        this.timeOut = timeOut;
        this.timeIn = timeIn;
        this.name = name;
        this.responseTo = responseTo;
        this.moduleFromName = moduleFromName;
        this.moduleFromType = moduleFromType;
        this.methodFromName = methodFromName;
        this.originalInputs = originalInputs;
        this.returnMethodToCall = returnMethodToCall;
        this.returnModuleToCall = returnModuleToCall;
        this.returnData = returnData;
    }
}

Here is the XactException class:

[DataContract]    
public class XactException
{
    [DataMember]
    string message;

    public XactException(string message)
    {
        this.message = message;
        // Add implementation.
    }
}

Update:

Ok so the comment from Daniel has helped me.

It looks now like the server is sending the callback to the client, but the client is throwing the following exception.

  • Caught: “The formatter threw an exception while trying to deserialize
    the message: There was an error while
    trying to deserialize parameter
    http://tempuri.org/:taskIn. The
    InnerException message was ‘Error in
    line 1 position 960. Element
    ‘http://schemas.datacontract.org/2004/07/:returnData’
    contains data from a type that maps to
    the name
    ‘http://schemas.datacontract.org/2004/07/:XactException’.
    The deserializer has no knowledge of
    any type that maps to this name.
    Consider using a DataContractResolver
    or add the type corresponding to
    ‘XactException’ to the list of known
    types – for example, by using the
    KnownTypeAttribute attribute or by
    adding it to the list of known types
    passed to DataContractSerializer.’.
    Please see InnerException for more
    details.”
    (System.ServiceModel.Dispatcher.NetDispatcherFaultException) Exception
    Message = “The formatter threw an
    exception while trying to deserialize
    the message: There was an error while
    trying to deserialize parameter
    http://tempuri.org/:taskIn. The
    InnerException message was ‘Error in
    line 1 position 960. Element
    ‘http://schemas.datacontract.org/2004/07/:returnData’
    contains data from a type that maps to
    the name
    ‘http://schemas.datacontract.org/2004/07/:XactException’.
    The deserializer has no knowledge of
    any type that maps to this name.
    Consider using a DataContractResolver
    or add the type corresponding to
    ‘XactException’ to the list of known
    types – for example, by using the
    KnownTypeAttribute attribute or by
    adding it to the list of known types
    passed to DataContractSerializer.’.
    Please see InnerException for more
    details.”, Exception Type =
    “System.ServiceModel.Dispatcher.NetDispatcherFaultException”
  • 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-22T21:21:19+00:00Added an answer on May 22, 2026 at 9:21 pm

    In your class

        [DataContract]
        public class XactTaskIn
    

    you have properties that return objects:

            [DataMember]
            public object[] originalInputs;
    
            [DataMember]
            public object returnData;
    

    WCF needs to know ahead of time what types can possibly be in there, so that it can tell the client (through the WSDL) what all the types are. For any/all non-‘native’ types (anything that isnt int, string, DateTime, etc) you will need to add a [KnownType] attribute for every possible type that might be passed back in those object properties, like this:

        [KnownType(typeof(XactException))]
        [KnownType(typeof(...))]
        [KnownType(typeof(...))]
        [DataContract]
        public class XactTaskIn
    

    That way when WCF builds the WSDL for the service, it will know to add XactException to the list of datatypes, and also the serializer will know to look for those classes.


    Side-note; if your client was built using SrvUtil, Service Reference, or generated from the WSDL in some way, you will need to rebuild the client after adding the [KnownType] attributes!

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

Sidebar

Related Questions

I am unsure where to place my business logic. I have a WCF service
My WCF Service is hosted in Windows Service and I have added some keys
We have a plugin system on a WCF service that checks libraries placed in
How to access App_Data folder in WCF service? I have placed a xslt file
I'm new here and I hope anyonte can help me. I have WCF Service
I have a WCF service that I have to reference from a .net 2.0
I have a WCF service hosted for internal clients - we have control of
I have a WCF service and I want to expose it as both a
I have a WCF service running on the IIS with a ServiceHostFactory. It's running
I have a WCF service, hosted in IIS 7.0 that needs to run database

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.