Bug 6734 - KnownTypes attribute not working on Synchronous Methods
Summary: KnownTypes attribute not working on Synchronous Methods
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-08-29 08:11 UTC by Oliver Waits
Modified: 2013-08-19 11:41 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Please note the file has been highly modified for my application. (18.51 KB, text/plain)
2012-08-29 08:11 UTC, Oliver Waits

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 6734 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Oliver Waits 2012-08-29 08:11:32 UTC
Created attachment 2430 [details]
Please note the file has been highly modified for my application.

Specifying a KnownType attribute on a WCF method that is synchronous will not work. This is due to the BaseMessageFormatter not copying the known types from the OperationDescription. When you try and run the client it will fail as it is not able to serialize the known type. Here is the fix which should be made to the BaseMessagesFormatter in the constructor. Previously if SyncMethod was not null it would return before copying the known types.

public BaseMessagesFormatter (OperationDescription desc)
			: this (desc.Messages)

            if (desc.SyncMethod != null)
                isAsync = false;
                requestMethodParams = replyMethodParams = desc.SyncMethod.GetParameters();
                isAsync = true;
                ParameterInfo[] methodParams = desc.BeginMethod.GetParameters();
                requestMethodParams = new ParameterInfo[methodParams.Length - 2];
                Array.Copy(methodParams, requestMethodParams, requestMethodParams.Length);
                methodParams = desc.EndMethod.GetParameters();
                replyMethodParams = new ParameterInfo[methodParams.Length - 1];
                Array.Copy(methodParams, replyMethodParams, replyMethodParams.Length);
            //Add the known types for serialization.
Comment 1 jonathan_chapman 2013-08-19 11:41:28 UTC
What did you do to work around this?

Seems like the fix is provided so why not implement?