locked
Deploying a WCF service RRS feed

  • Question

  • When I read this line : https://docs.microsoft.com/en-us/dotnet/framework/wcf/deploying-a-wcf-library-project

    "However, the App.config file is not recognized after deployment. You have to move your configuration code into the configuration file recognized by your hosting environment. For self-hosting, you should copy the contents of the App.config file into the App.config file of the hosting executable. If you use IIS to host your service, you should copy the contents of the App.config file into the Web.config file of the virtual directory."

    I used the template to create a service ( no modificaton ) and the 2 files C:\Users\me\Documents\Visual Studio 2017\Projects\wcf2\wcf2\Web.config and C:\Users\me\Documents\Visual Studio 2017\Projects\wcf2\wcf2\bin\wcf2.dll.config

    are identical .. so what is intended ??

    Thanks


    andrew

    Tuesday, September 5, 2017 6:24 PM

Answers

  • An app.config is only used in debug runtime mode in Visual Studio.

    For IIS hosted solutions, the Web.config file is where .NET will look for any configuration information during application runtime. Any projects below the Web project, the root project, within the solution that have an app.config, the app.config information in the subordinate project must be copied to the web.config in the root project.

    If a project that creates a programname.exe file, a selfhosting exe, has an app.config, which is the root project, then another project within the solution that has an app.config, the app.config information in the subordinate project must be copied to the app.config in the root project.

    Why? It is because upon the successful build of solution, the root selfhosting exe project, VS will have its app.config copied over to a runtime config called programname.exe.config where .NET will look for config information at program runtime.

    The progamname.exe is deployed, and the progamname.exe.config must be deployed to the same location so .NET can find it.

    • Marked as answer by andrewcw Wednesday, September 6, 2017 4:51 AM
    Tuesday, September 5, 2017 7:53 PM