none
Correspondence between commands in App.config and commands in "C#" .NET algorithm ... RRS feed

  • Question




  • Hello,

    I would like to ask you


    how can I replace all nodes - expressions in app.config file with commands in normal algorithm i.e. WITHOUT app.config file.

    for example XML code in app.config can be replaced with this:

    ...

    ...

    ServiceHost sh = null; string strAdr = @"net.tcp://10.0.0.2:9000/test"; try { Uri uriAddr = new Uri(@"net.tcp://10.0.0.2:9000/test"); sh = new ServiceHost(typeof(Service1), uriAddr); ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); sh.Description.Behaviors.Add(smb); sh.AddServiceEndpoint(typeof(IService1), MetadataExchangeBindings.CreateMexTcpBinding(), "mex"); NetTcpBinding ntb = new NetTcpBinding(); ntb.Name = "NewBinding0"; ntb.Security.Mode = SecurityMode.Transport; ntb.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; ntb.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; ntb.Security.Message.ClientCredentialType = MessageCredentialType.Windows; sh.AddServiceEndpoint(typeof(IService1), ntb, uriAddr); sh.Open();

    ...

    ...

    but how can I find direct correspondence between commands in app.config 

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">

    and programmatic replacement of it (maybe, maybe it is not direct relacement):

     ServiceMetadataBehavior smb = new ServiceMetadataBehavior();

    Can you recommend me some suitable book ? or web page where everything this is described ?

    Many thanks..

    Jerry

    Friday, March 24, 2017 4:04 PM

Answers

  • >><serviceHostingEnvironment multipleSiteBindingsEnabled="true">

    We could not implement this in Code.

    ServiceHost is used to configure and expose a service when you are not using IIS.

    multipleSiteBindingsEnabled is only available to WCF services that are hosted under IIS.

    >>Can you recommend me some suitable book ? or web page where everything this is described ?

    There is no book to describe this together, Windows Communication Foundation is a good document to learn WCF basic knowledge.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 27, 2017 2:00 AM
  • I am somewhat disappointed. I thought that there is direct correspondence between each command in app.config and in a "command" in C# .NET. huh...

    I found e.g. this:

    https://www.codeproject.com/Articles/642444/Creating-and-consuming-a-simple-WCF-Service-withou

    but there is missing IMathService code and I am not able to reproduce it.

    never mind ..


    • Marked as answer by Jerry.Mouse Tuesday, March 28, 2017 7:26 AM
    Monday, March 27, 2017 1:10 PM

All replies

  • >><serviceHostingEnvironment multipleSiteBindingsEnabled="true">

    We could not implement this in Code.

    ServiceHost is used to configure and expose a service when you are not using IIS.

    multipleSiteBindingsEnabled is only available to WCF services that are hosted under IIS.

    >>Can you recommend me some suitable book ? or web page where everything this is described ?

    There is no book to describe this together, Windows Communication Foundation is a good document to learn WCF basic knowledge.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 27, 2017 2:00 AM
  • I am somewhat disappointed. I thought that there is direct correspondence between each command in app.config and in a "command" in C# .NET. huh...

    I found e.g. this:

    https://www.codeproject.com/Articles/642444/Creating-and-consuming-a-simple-WCF-Service-withou

    but there is missing IMathService code and I am not able to reproduce it.

    never mind ..


    • Marked as answer by Jerry.Mouse Tuesday, March 28, 2017 7:26 AM
    Monday, March 27, 2017 1:10 PM
  • >> but there is missing IMathService code and I am not able to reproduce it.

    IMathService is an Interface for service, I think you could define it with your own service interface.

    If you have any issue while developing WCF service, please feel free to post in this forum, and share us detailed steps to reproduce your issue.

    If there is no other issue for current thread, I would suggest you mark the helpful reply as answer to close this thread.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 28, 2017 2:06 AM