I've been working on creating a self hosted application server in F#. I have the app server up and running and I can connect using a C# client, but some of the things that I want to do are better served using F#. The problem is that I can't seem to get the F# client to work properly. I've found a few examples, but I can't seem to get any of them to work. The most promising is here. Following that example I came up with the following code:
let address= new EndpointAddress("net.tcp://192.168.101.100:2009/PrevisionService/tcp")
let factory = new ChannelFactory<IPrevisionAppServer>("NetTcpBinding_IPrevisionAppServer", address)
let channel = factory.CreateChannel()//address)
let GetDataObject (sql) = channel.GetDataObject(sql)
factory.Close()
but I get the following error:
Could not find endpoint element with name 'NetTcpBinding_IPrevisionAppServer' and contract 'PrevisionAppServer.Main+IPrevisionAppServer' 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 name could be found in the client element.
I do have an app.config file, and it works just fine in C#:
<?xml version="1.0" encoding="utf-8"?>
<!--Client Config-->
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IPrevisionAppServer" closeTimeout="00:01:00"
openTimeout="00:20:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://192.168.101.100:2009/PrevisionService/tcp" behaviorConfiguration="ServiceViewEventBehavior"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IPrevisionAppServer"
contract="*" name="NetTcpBinding_IPrevisionAppServer">
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceViewEventBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>`
For whatever reason, it seems to be ignoring the app.config file. Any ideas? Is there better code to get this working? Any would be appreciated!
UPDATE: Okay, I feel stupid, but I failed to notice that I was running this in a test client that also had a C# UI as the startup, therefore the app.config is in the C# project. So, now the questions becomes, how to I apply the C# app.config to the F# project (I need it this way)? Meaning, I don't really want to code all the getting and setting of properties from the app settings to code. Ideas?