0

I have been looking for a solution on the web, but I found no right solution to solve my problem:

I must create an Outlook addins which uses a "Service References". This one can have 4 different endpoint address (choosen by the user).

To reach the endpoint of my service, I have found this:

var appConfig = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
var serviceModel = System.ServiceModel.Configuration.ServiceModelSectionGroup.GetSectionGroup(appConfig);
var clientEndpoints = serviceModel.Client.Endpoints;

In my app.config the service is written like this (because of privacy, I have modified some values):

<system.serviceModel>
  <bindings>
   <basicHttpBinding>
    <binding name="nameSOAPBinding">
     <security mode="Transport" />
    </binding>
     <binding name="nameSOAPBinding1"/>
   </basicHttpBinding>
  </bindings>
  <client>
   <endpoint address="endpointAddress"
    binding="basicHttpBinding" bindingConfiguration="contractNameSOAPBinding"
    contract="contractName" name="contractNameSOAP11" />
  </client>
</system.serviceModel>

After exploring the C# var 'clientEndpoints' in details, I have not found the endpoint value (= the address) where I could have set the new value.

I am only looking for solution to modify the endpoint address value from C#. Am I on the right way? Is there a easier/better solution?

gim
  • 1
  • I suspect your Addin's App.config will not be found because the Outlook executable running your Addin is pointing somewhere else. You will have to create binding and endpoint completely programmatically. – Filburt Sep 16 '16 at 08:28
  • Thanks for your replies. I have found a solution here (answer 3 by realbizkit): http://stackoverflow.com/questions/966323/how-to-programmatically-modify-wcf-app-config-endpoint-address-setting – gim Sep 16 '16 at 11:30

0 Answers0