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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:57:19+00:00 2026-05-23T09:57:19+00:00

I’ve managed to get WCF callback (over NamedPipes) working with strings, but I sadly

  • 0

I’ve managed to get WCF callback (over NamedPipes) working with strings, but I sadly can’t get it to work with custom classes.

Here’s the service declaration + implementation:
http://pastebin.com/Zayi2kjT

here is my data contract:
http://pastebin.com/wFCxrRcJ

here is what I’m doing on the client side:
http://pastebin.com/jxEbyEtP

When I change

    public void Send()
    {
        try
        {
            channel.OnCallback("I love deadlines. I like the whooshing sound they make as they fly by.");
        }
        catch (Exception ex)
        {
            Form1.AddText(ex.GetType() + "|" + ex.Message);
        }
    }

to

channel.OnCallback(new TransmissionClass("I love deadlines. I like the whooshing sound they make as they fly by."));

I get the following exception on the server when invoking the callback method(see above):

System.ServiceModel.FaultException
Der Formatierer hat beim Deserialisieren der Nachricht eine Ausnahme ausgelöst:   
Fehler beim Deserialisieren von Parameter http://tempuri.org/:aUpdatedObject.  
Die InnerException-Nachricht war "Das Element "http://tempuri.org/:aUpdatedObject"  
enthält Daten eines Typs, der dem Namen "http://schemas.datacontract.org/2004/07
/ServerApp:TransmissionClass" zugeordnet ist.   
Dem Deserialisierungsprogramm ist kein Typ bekannt, der diesem Namen zugeordnet ist.  
Verwenden Sie ggf. einen DataContractResolver, oder fügen Sie den entsprechenden Typ für "TransmissionClass" der Liste der bekannten Typen hinzu.  
Verwenden Sie dazu z. B. das Attribut "KnownTypeAttribute", oder fügen Sie den Typ der an DataContractSerializer übergebenen Liste von bekannten Typen hinzu.".  
Weitere Details finden Sie unter "InnerException".

However, I have applied the KnownTypeAttribute to the WCF service implementation.

  • 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-23T09:57:19+00:00Added an answer on May 23, 2026 at 9:57 am

    In general, whoever (server or client) is deserialising a parameter or return value needs to know what types (rather, what contracts) to expect at runtime in order to do so. In this case, a declared parameter of type object doesn’t give the client enough information to deserialise whatever the server might be sending back to it. Replacing it with a type supported by the DataContractSerializer (and decorated with [KnownType], if the server plans to send subclass instances in the callback) solves this problem.

    You can also use configuration to tell the DataContractSerializer about known types, but this is application-wide and seems like a bit of a blunt instrument to me.

    I had an obscure case once where my contracts looked something like this:

    [ServiceContract]
    interface ISearch
    {
        [OperationContract]
        SearchResult Search(SearchQuery query);
    }
    
    [DataContract]
    [KnownType(typeof(Subclass1InSharedAssembly)), etc...]
    class SearchResult
    {
        [DataMember]
        BaseClassDeclaredInSharedAssembly Value { get; set; }
    }
    

    Because I wanted the server and client to use the (useful) shared assembly types, I had a reference to the shared assembly in both and chose not to generate any proxy types for them… and so svcutil didn’t generate any KnownTypeAttributes for me. Partial classes saved my bacon; On the client, you can do this:

    // generated proxy .cs
    [DataContract]
    partial class SearchResult
    {
        ...
    }
    
    // hand-written .cs
    [KnownType(typeof(Subclass1InSharedAssembly)), etc.]
    partial class SearchResult
    {
        // Now the client knows how to deserialise derived types.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT

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.