0

I wrote a dll project in c#. I added a service reference. A app.config was automatically generated. In the same solution I have an asp.net project.

If I copy paste the relevant configuration from the app.config to the web.config and change the client url - will it override the service url in the app.config?

The funny thing is that everything works OK even without copying this section to the web.config. How come?

TIA

dkackman
  • 15,179
  • 13
  • 69
  • 123
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
  • 1
    Your web project will ignore your other project's app config. So I'd say you *have* to. – bzlm Oct 02 '11 at 20:25
  • @bzlm :thanks. but the funny thing is that everything works OK even without copying this section to the web.config. How come? – Elad Benda Oct 02 '11 at 20:39

1 Answers1

2

Yes.

The config schema is the same for web and app.config. There are some sections that will only make sense for web apps, but generally not the other way around. You should be just fine copy-pasting your configuration.

The web project only looks at Web.config, so you will need to copy the configuration to your web.config.

driis
  • 161,458
  • 45
  • 265
  • 341
  • thanks. but the funny thing is that everything works OK even without copying this section to the web.config. How come? – Elad Benda Oct 02 '11 at 20:39
  • 1
    I would guess that some default settings are used. The designer might be generating a hardcoded url for the project to use if the config is missing. You can try looking at the designer generated code to see what it reveals. – driis Oct 02 '11 at 20:43
  • i'll try. But basically you say the web.config overrides the app.config of the dll it uses. – Elad Benda Oct 02 '11 at 21:16
  • 1
    @EladBenda, No, that's not how it works. The web project doesn't even know about the app.config of the other project. When the web project is running, that configuration file isn't involed. – bzlm Oct 02 '11 at 21:19