hi, i'm trying to setup net.tcp on WAS with 0 config, that is, i want to setup everything programmatically (as in a windows service).
I've tried to put this code in the AppInitialize method
ServiceHosthostSystem = newServiceHost(typeof(WKI.Cosmo.Business.ClientServices));
BindingtcpBinding = newNetTcpBinding(SecurityMode.None, true); hostSystem.AddServiceEndpoint(typeof(WKI.Cosmo.Interop.IClientServices), tcpBinding, "IClientServices2.svc");
this code is called but gives the following error.
System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are .
This makes somehow sense, however of course i do not wabnt to register a base address since i'm hosted in IIS/WAS. Seems like this method is called to early.
Is what i'm trying to do a supported way ? Is there any solution ?
using ServiceHostFactory u can control the service instance to setup (i use it for a singelton as well), and other nice stuff.
But how can i have no info in the web.config at all, still have IIS/WCF landing on my factory ?
I think i need to hook something before in the call chain to do that. Appinitialize seems a nice place, however , from the error i get i don't kow how to grab the baseaddress (net.tcp://myserver/myvdir)., and i don't want to hardocode it.
I hope i explained myself clearly now :)
ok .. i checked out better the documentation . with ServiceHostFactory i can control service instance AND it's endpoint construction .. so i can get rid of that stuff from the config ..
But is there a way to get rid of svc files or the serviceactivations elments in the config fle .. and write this stuff in code as well ? appinitialize seems a good place but i don't know how to pick up the baseaddresses from IIS/WAS. (writing them in my custom section of the config file is not a good idea)
As Sabbadin metioned, you could use the ServiceHostFactory class to use a custom ServiceHost in the IIS or WAS hosting environment, it provides CreateServiceHost method one of which parameter is baseAddress, as for this, please check this article.