WCF December CTP: factories, proxies, yet again.
Here's something that I didn't expect. Do people have the same result I do? After the preceding post, I expected this to run correctly, and it doesn't.
ChannelFactory<ISampleService> factory = new ChannelFactory<ISampleService>();
foreach (ServiceEndpoint point in endpoints)
{
if (point != null)
{
factory.Description.Endpoint.Address = point.Address;
factory.Description.Endpoint.Binding = point.Binding;
serviceChannel = factory.CreateChannel();
Console.WriteLine(
serviceChannel.SampleMethod("Client used the "
+ point.Address.ToString()
+ " address.")
);
}
}
factory.Close();
Instead, this miserable information:
System.ArgumentException was unhandled
Message="The provided URI scheme 'net.tcp' is invalid; expected 'http'.\r\nParameter name: via"
Source="System.ServiceModel"
ParamName="via"
StackTrace:
at System.ServiceModel.Channels.TransportChannelFactory.ValidateScheme(Uri via)
at System.ServiceModel.Channels.HttpChannelFactory.OnCreateChannel[TChannel](EndpointAddress remoteAddress, Uri via)
at System.ServiceModel.Channels.ChannelFactoryBase.CreateChannel[TChannel](EndpointAddress remoteAddress, Uri via)
at System.ServiceModel.Channels.ServiceChannelFactory.MaybeCreateInnerChannelBinder(IEnumerable`1 supportedChannels, Boolean actuallyCreate, EndpointAddress to, Uri via, IChannelBinder& result)
at System.ServiceModel.Channels.ServiceChannelFactory.CreateInnerChannelBinder(EndpointAddress to, Uri via)
at System.ServiceModel.Channels.ServiceChannelFactory.CreateChannel(Type channelType, EndpointAddress to, Uri via)
at System.ServiceModel.Channels.ServiceChannelFactory.OnCreateChannel[ChannelType](EndpointAddress to, Uri via)
at System.ServiceModel.Channels.ChannelFactoryBase.CreateChannel[TChannel](EndpointAddress remoteAddress)
at System.ServiceModel.ChannelFactory`1.CreateChannel()
at Client.Main() in D:\RefSamples\MetadataResolver\CS\Client.cs:line 57
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
So depressing. The via is not getting reestablished. Hmmm. I'll investigate.