.NET - deploying a WCF client, without an app.config

前端 未结 2 910
猫巷女王i
猫巷女王i 2020-12-24 14:25

I\'m writing a client to a WCF service. This is a single app in a larger system that includes modules written in C#, C++, VB, and Java. All of the apps share common config

2条回答
  •  猫巷女王i
    2020-12-24 14:38

    You can use the following code to creating the bindings which is what the config is doing. I am not sure whether that will let you remove the file altogether but the application won't use the config if this is the case. Put your own values in the timeouts, etc.

        var binding = new WSHttpBinding();
        binding.SendTimeout = new TimeSpan(0, 0, 0, 0, 100000);
        binding.OpenTimeout = new TimeSpan(0, 0, 0, 0, 100000);
        binding.MaxReceivedMessageSize = 10000;
        binding.ReaderQuotas.MaxStringContentLength = 10000;
        binding.ReaderQuotas.MaxDepth = 10000;
        binding.ReaderQuotas.MaxArrayLength = 10000;
        var endpoint = new EndpointAddress("http://localhost:57102/MyService.svc");
        var myClient = new WebServiceclient(binding, endpoint);
    

提交回复
热议问题