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, eg Message, Transport, None).
What do I need to change/put in to my constructor to be able to get the binding to work correctly?
Config has 'net.tcp://example.com/MyApp/DomainManagement' as the URL. But your code has 'net.tcp://example.com/MyApp/DatabaseManagement'. That could be the mismatch.
It's not a good idea to modify generated proxies. But since you have decided to hard code the URL and binding you may do like below from your application code.
DomainManagementClient client = new DomainManagementClient(new NetTcpBinding(SecurityMode.None), new EndpointAddress("net.tcp://example.com/MyApp/DatabaseManagement"));
A generated service proxy should automatically have this overload taking in the binding and address to point to.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.