Bug 40064 - [MONO] Service Endpoint - EndpointBehaviors Not Implement
Summary: [MONO] Service Endpoint - EndpointBehaviors Not Implement
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: 4.2.0 (C6)
Hardware: PC All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2016-04-02 08:43 UTC by Matthew
Modified: 2017-09-06 16:55 UTC (History)
2 users (show)

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


Description Matthew 2016-04-02 08:43:46 UTC
When creating a WCF client in a PCL (targetting .NET Core) you must use EndpointBehaviors and not Behaviors. This works fine in a Windows RT application, but Mono has not implemented this so produces NotImplementedException in Android and iOS.


		public KeyedByTypeCollection<IEndpointBehavior> Behaviors {
			get { return behaviors; }

		public KeyedCollection<Type,IEndpointBehavior> EndpointBehaviors {
			get { throw new NotImplementedException (); }
Comment 1 Wayne Stewart 2016-05-18 15:24:10 UTC
I also encountered this bug today. I was able to work around it with reflection and found a similar problem with the ClientMessageInspectors property on the System.ServiceModel.Dispatcher.ClientRuntime class.

//Workaround for accessing Behaviors on a ServiceEndpoint
//client.Endpoint.EndpointBehaviors.Add(new EndpointBehavior());

//client is of type System.ServiceModel.ClientBase<T>
var prop = client.Endpoint.GetType()
var obj = (KeyedCollection<Type, IEndpointBehavior>)prop
obj.Add(new EndpointBehavior());

//Workaround for accessing MessageInspectors on a ClientRuntime
//clientRuntime.ClientMessageInspectors.Add(new MessageInspector());

var prop = clientRuntime.GetType()
var obj = (ICollection<IClientMessageInspector>)prop
obj.Add(new MessageInspector());
Comment 2 Matthew 2016-05-18 15:28:41 UTC
Does this workaround also work on iOS given that it is restrictive on how you can use reflection?
Comment 3 Wayne Stewart 2016-05-18 15:34:02 UTC
I wrote this while working on the iOS version of the project. I have not tested in Android yet.
Comment 4 Matthew 2016-05-24 13:02:48 UTC
Great work Wayne Stewart - I've got this working across Windows RT, Android and iOS using your workaround for Android and iOS and using the .NETCore code for Windows.

Now I'm no longer using APIs that prevent the Windows Store version passing certification.

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