none
how to read msmqIntegrationBinding section from app.config in C# RRS feed

  • Question

  • Hi I am using WCF framework.My problem is I am unable to read msmqIntegrationBinding section from app.config.

    I want to read the value of recieveRetryCount.

     <msmqIntegrationBinding>
            <binding name="OrderProcessorBinding" maxRetryCycles="0" receiveErrorHandling="Move"
              receiveRetryCount="3" retryCycleDelay="00:00:59">
              <security mode="None" />
            </binding>
          </msmqIntegrationBinding>

    Please tell me..I am new to all these.I wrote something like below, but not able to move ahead.

      var config = ConfigurationManager.GetSection("system.serviceModel/bindings") as
                            System.ServiceModel.Configuration.BindingsSection;
               // foreach (ChannelEndpointElement bindings in config.BasicHttpBinding)
                //{
                MsmqIntegrationBindingCollectionElement bindings = config.MsmqIntegrationBinding;

    Thanks in Advance

    Friday, March 8, 2013 11:07 AM

Answers

  • Following on from the code above you could do the following:

    var config = ConfigurationManager.GetSection("system.serviceModel/bindings");
               
    var msmqIntegrationBinding = ((System.ServiceModel.Configuration.BindingsSection)config).MsmqIntegrationBinding;
    
    int recieveRetryCount = msmqIntegrationBinding.Bindings[0].ReceiveRetryCount;


    • Edited by JayChase Monday, March 11, 2013 6:33 AM
    • Marked as answer by samashti Monday, March 11, 2013 6:41 AM
    Monday, March 11, 2013 6:32 AM

All replies

  • This link might help you 

    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Friday, March 8, 2013 11:11 AM
  • Hi Rohit,

    Mark is explained to get the Custom section(config section).But I am asking the standard one.Any Idea how to read ?

    msmqIntegrationBinding section


    Friday, March 8, 2013 11:30 AM
  • This works for me:

    var config = ConfigurationManager.GetSection("system.serviceModel/bindings");
    
    var msmqIntegrationBinding = ((System.ServiceModel.Configuration.BindingsSection)config).MsmqIntegrationBinding;

    Let me know how you get on.
    Friday, March 8, 2013 12:05 PM
  • Thank you very much Chase......

    But after getting the msmqIntegrationBinding variable how to get recieveRetryCount????

    I am unable to proceed further.

    Please help me and provide me solution.Actually I am new to MSMQ.

    Thanks

    Monday, March 11, 2013 6:01 AM
  • Following on from the code above you could do the following:

    var config = ConfigurationManager.GetSection("system.serviceModel/bindings");
               
    var msmqIntegrationBinding = ((System.ServiceModel.Configuration.BindingsSection)config).MsmqIntegrationBinding;
    
    int recieveRetryCount = msmqIntegrationBinding.Bindings[0].ReceiveRetryCount;


    • Edited by JayChase Monday, March 11, 2013 6:33 AM
    • Marked as answer by samashti Monday, March 11, 2013 6:41 AM
    Monday, March 11, 2013 6:32 AM
  • Thank you very much Chase.........

    It worked......Thanks a lot ....You are awesome...

    Monday, March 11, 2013 6:41 AM