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 (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-08-29 08:11 UTC by Oliver Waits
Modified: 2013-08-19 11:41 UTC (History)
2 users (show)

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


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

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();
            }
            else
            {
                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.
            operation_known_types.AddRange(desc.KnownTypes);	
		}
Comment 1 jonathan_chapman 2013-08-19 11:41:28 UTC
Oliver,
What did you do to work around this?

Xamarin,
Seems like the fix is provided so why not implement?

Note You need to log in before you can comment on or make changes to this bug.