I have a WCF service that works fine with an app.config file. I decided to move this app.config stuff to the code so I have better control. I tried the following:
string localIP = GetLocalIP();
int PrimaryPort = 9900;
Uri PrimaryUri = new Uri(String.Format("net.tcp://{0}:{1}/", localIP, PrimaryPort));
int MetaPort = 9901;
Uri MetaUri = new Uri(String.Format("http://{0}:{1}/", localIP, MetaPort));
AES_MarketDataService aes = new AES_MarketDataService();
using (ServiceHost aesHost = new ServiceHost(aes, MetaUri, PrimaryUri))
{
NetTcpBinding PrimaryBinding = new NetTcpBinding();
PrimaryBinding.Name = "AES";
PrimaryBinding.ReceiveTimeout = new TimeSpan(0, 0, 10);
PrimaryBinding.Security.Mode = SecurityMode.Transport;
PrimaryBinding.ReliableSession.Enabled = true;
ServiceMetadataBehavior mexBehavior = new ServiceMetadataBehavior();
mexBehavior.HttpGetEnabled = true;
aesHost.Description.Behaviors.Add(mexBehavior);
aesHost.AddServiceEndpoint(typeof(IAES_MarketDataService), PrimaryBinding, "AES");
aesHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
aesHost.Open();
Console.WriteLine("Host started at {0}: svc={1}, meta={2}", DateTime.Now, PrimaryUri.AbsoluteUri, MetaUri.AbsoluteUri);
Console.ReadLine();
}
This works, but for some reason, the client faults a few seconds after its first call to the service. There is no exception on the server side, and if I restart my client, I am perfectly able to make another call (which will again fault the client after a few seconds).
What is this code missing that the app.config file is not?