Bug 18808 - WCF net tcp export metadata
Summary: WCF net tcp export metadata
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: 3.0.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-04-03 23:15 UTC by Hugo Arevalo
Modified: 2017-09-06 16:55 UTC (History)
2 users (show)

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


Attachments
Source file to test the bug. (1.33 KB, text/x-csharp)
2014-04-03 23:15 UTC, Hugo Arevalo
Details

Description Hugo Arevalo 2014-04-03 23:15:42 UTC
Created attachment 6491 [details]
Source file to test the bug.

Hi, I'm trying to export the metadata of a WCF nettcp service, the service works fine if I don't want to export metadata but It's a pain on the neck having to copy the assembly to the client application whenever I make a change on the server. I replicated a small example to show the exception I'm receiving. The application works just fine on Visual Studio.

In order to compile the service I run: gmcs -r:System.ServiceModel Main.cs
To run the service I just type: mono Main.exe
Comment 1 Hugo Arevalo 2014-04-04 11:03:07 UTC
Sorry, I forgot to comment that the address is set as localhost, I'll post the code also here.

using System;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace wcfservice
{
	public class Program
	{
		public static void Main(string[] args)
		{
			var uri = new Uri("net.tcp://localhost:9001/HelloService");
			var host = new ServiceHost(new HelloWorld(), uri);
			
			host.AddServiceEndpoint(typeof(IHelloWorld), new NetTcpBinding(SecurityMode.None), uri);
			ServiceMetadataBehavior smb = host.Description.Behaviors.Find<ServiceMetadataBehavior>();

			if (smb == null)
				smb = new ServiceMetadataBehavior();

			host.Description.Behaviors.Add(smb);

			host.AddServiceEndpoint(
				ServiceMetadataBehavior.MexContractName,
				MetadataExchangeBindings.CreateMexTcpBinding(),
				"mex");

			var behavior = host.Description.Behaviors.Find<ServiceBehaviorAttribute>();
			behavior.InstanceContextMode = InstanceContextMode.Single;
			host.Open();

			Console.WriteLine("Hosted {0}", DateTime.Now.ToString());
			Console.ReadKey();
		}	
	}

	[ServiceContract]
	public interface IHelloWorld
	{
		[OperationContract]
		string Hello(string Name);
	}
	[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single, IncludeExceptionDetailInFaults=true,ConcurrencyMode=ConcurrencyMode.Reentrant)]
	public class HelloWorld : IHelloWorld
	{
		public string Hello(string Name)
		{
			return string.Format("Hello {0}", Name);
		}
	}
}

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