C # wcf - exception that occurred when open () was called in proxy class

I have the following problem: basically I have a WCF service that works fine in small tests. However, when I try to execute a test package / download, I get a message InvalidOperationExceptionwith a message when the open () method is called in the proxy class:

"The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be changed while it is in the Opened state."

I searched google but can't find anyone who is really quoting this exception message.

I suppose that for diagnostics additional information about the service may be required - when a service receives data through one of its public methods, it mainly performs some processing and routes the data to the data-related service (different data will lead to different routing). To ensure that the service runs as fast as possible, each cycle of receiving, processing and routing data is processed by a separate thread in the stream pool. could this be a problem arising from one thread causing proxyClass.Open()while another is already using it? if the block lockfixed this problem, if it really is a problem?

Thank you guys - I’ve already worked on this project for too long , and finally want to see it, but this seems to be the last stumbling block, so any help is greatly appreciated :-)

==================================================== ========================

thanks for not using the usingWCF proxy construct . However, the MSDN article is not the most clearly written literature, so one quick question is: should I use a proxy server as such:

try
{
    client = new proxy.DataConnectorServiceClient();
    client.Open();
    //do work
    client.Close();
 }
 .................. //catch more specific exceptions
 catch(Exception e)
 {
    client.Abort();
 }
+3
source share
4 answers

How do you use proxies? Create a new proxy object for each call. Add code about how you use proxies.

- - , -, . proxy.open() , . .

- , wcf - . , , .

if (proxy.State == CommunicationState.Faulted)
{
    proxy.Abort();
}
else
{
    try
    {
        proxy.Close();
    }
    catch
    {
        proxy.Abort();
    }
}

? http://msdn.microsoft.com/en-us/library/aa355056.aspx

, , , . wcf , catch Excelion .

try
{
    ...
    client.Close();
}
catch (CommunicationException e)
{
    ...
    client.Abort();
}
catch (TimeoutException e)
{
    ...
    client.Abort();
}
catch (Exception e)
{
    ...
    client.Abort();
    throw;
}

, , dispose wcf.

.Open(), , .

+2

, .NET 3.5 . .NET 3.5 WCF ClientBase'1 ( ) ChannelFactories/Channels. , / , ( , Binding, ), , . , .Open() , .Created.

+2

, Open() .

+1

Source: https://habr.com/ru/post/1704892/


All Articles