I am trying to get rid of the app.config file for a WCF project, I need the setting to be hard-coded in to the DLL I am generating.
I created my proxy class with svcUtil
and the client works fine when I use App.config
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="ManagementEndpoint">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://example.com/MyApp/DomainManagement"
binding="netTcpBinding" bindingConfiguration="ManagementEndpoint"
contract="MyApp.DomainManagementProxy.IDomainManagement"
name="DomainManagementEndpoint" />
</client>
</system.serviceModel>
However If I remove my App.config
and replace the default constructor with the following
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class DomainManagementClient : System.ServiceModel.ClientBase<MyApp.DomainManagementProxy.IDomainManagement>, MyApp.DomainManagementProxy.IDomainManagement
{
public DomainManagementClient()
: base(new NetTcpBinding(SecurityMode.None, false),
new EndpointAddress("net.tcp://example.com/MyApp/DatabaseManagement"))
{
}
//(Snip)
it gives me the following error as soon as I call the first method in the client
The message with Action 'http://example.com/MyApp/DomainManagement/IDomainManagement/GetServerSetup' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
What do I need to change/put in to my constructor to be able to get the binding to work correctly?