I cannot get Windsor WCF facility to generate client endpoints without them being explicitly defined in the Web/App.config file.
My contracts, clients, and callbacks were generated as a service reference, and I want to register everything programmatically without using config files. However, I am receiving this error when the endpoint information is not present in the App/Web.config:
Error: Could not find default endpoint element that references contract 'ServiceReference1.IWcfContract' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
Registration
Component.For<IWcfContract>()
.ImplementedBy<WcfContractClient>()
.AsWcfClient(new DefaultClientModel(
WcfEndpoint
.ForContract<IWcfContract>()
.BoundTo(MyConfig.NetTcpBinding)
.At(MyConfig.WcfHostAddressAndPort)),
.LifestyleTransient());
Component.For<IWcfContractClientFactory>()
.AsFactory(new WcfContractClientFactorySelector())
Typed Factory
IWcfContractCreate(WcfContractClientCallback callback);
void Release(IWcfContractinstance);
Factory Selector
public class WcfContractClientFactorySelector : DefaultTypedFactoryComponentSelector
{
protected override IDictionary GetArguments(MethodInfo method, object[] arguments)
{
Arguments args = new Arguments();
args.Add("callbackInstance", new InstanceContext(arguments[0]));
return args;
}
}
Resolving the Client
IWcfContractClientFactory factory = container.Resolve<IWcfContractClientFactory>();
IWcfContract client = factory.Create(new WcfContractClientCallback());
At this point, if I have the endpoint information in the Web/App.config file, then everything works fine. If I take it out, I receive the error mentioned above. Thanks!
MyConfig
? Seems like that would have something to do with it if it's trying to go to the App.config. – Patrick QuirkMyConfig
points to, right? Maybe if you posted a small part of the App.config that shows what you're removing (commented out) and whatMyConfig
points to. IsMyConfig
your class, or a 3rd party class? – Patrick QuirkServiceContractAttribute
on the service reference contract interface which is pointing to the App/Web.config file. I've removed it, but now have other errors. I'll post an answer shortly. – Steven