Back to list
Views:   0
Replies:  0
Reply 1
I finally solved the second issue the WCF timout.
In my application I have enabled my WCF service via a COM object for legacy applications that need my WCF service.
Trouble is that COM object (being a class library) does not have app.config and so I added code to read a configuration file effectively bypassing my app.config settings. Hence the symptom that whatever I did in the app.config has no effect on the WCF service at all.

I added in the C# code, assignments for wsHttpBinding settings such as maxBufferPoolSize = 2147483647 and so forth.
Once I have done this my WCF service start working like a charm.

For those of you who are interested I have included the relevant section of my C# code.

I still do not know however why there are two app.config files in the Windows Forms project in Patterns in Action.

ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); 

            // Force reading configuration from a specific file in-place of the app.config that is usually used.
            fileMap.ExeConfigFilename = @"C:\Program Files\Application.exe.config";  
            Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); 

            // Read the endpoint from the configuration file.
            ConfigurationSectionGroup csg = config.GetSectionGroup("system.serviceModel"); 
            ConfigurationSection css = csg.Sections["client"]; 
            ClientSection cs = (ClientSection)csg.Sections["client"]; 
            ChannelEndpointElement endPoint = cs.Endpoints[0]; 
            string endPointString = endPoint.Address.ToString(); 

            // Use wsHttpBinding.
            WSHttpBinding wsBinding = new WSHttpBinding(); 
            // Enable reliable session.
            OptionalReliableSession rl = wsBinding.ReliableSession; 
            rl.Enabled = true;             
            EndpointAddress endpointAddress = new EndpointAddress(endPointString); 
            // Set values for endpoint. These values are normally set in app.config.
            // Note the max limit 2147483647 or the service will throw errors when sending back to client a large collection.
            TimeSpan ts = new TimeSpan(0, 30, 0); 
            wsBinding.ReceiveTimeout = ts; 
            wsBinding.MaxBufferPoolSize = 2147483647; 
            wsBinding.MaxReceivedMessageSize = 2147483647; 
            wsBinding.ReaderQuotas.MaxArrayLength = 2147483647; 
            wsBinding.ReaderQuotas.MaxBytesPerRead = 2147483647; 
            wsBinding.ReaderQuotas.MaxDepth = 2147483647; 
            wsBinding.ReaderQuotas.MaxStringContentLength = 2147483647; 
            wsBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647; 

            // Get a new instance of the application service using the settings that were set above.
            Service = new ApplicationServiceClient(wsBinding, endpointAddress); 

Menashay Givoni, Nov 07, 2010
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas