1

I'm using this code (in my DAL project):

ConfigurationManager.AppSettings["server"]

to access appsettings section in web.config file (from web project):

<appSettings>
<add key="server" value="server.name.com"/>
<add key="database" value="databasename"/>
</appSettings>

and in a Web.Debug.config I'm using a following transformation

<add key="server" value="MY-LAPTOP"
     xdt:Locator="Match(key)" xdt:Transform="Replace"/>

after that when I start application the config file isn't transformed. First line of code returns the nontransformed infromation. What's wrong with the code? What am i missing?

I have tried to publish it and when I check config file everything is ok like it is ment to be.

Sayed Ibrahim Hashimi
  • 43,864
  • 17
  • 144
  • 178
Ante
  • 8,567
  • 17
  • 58
  • 70
  • 1
    do you get a runtime error? How do you know it wasn't transformed? What evidence lead you to that? Can you give us more info about how you are doing the transformation? – JustBeingHelpful Jan 05 '12 at 00:48
  • For transformation I used that code (3rd) in web.debug.config and I have tested it looking what ConfigurationManager returns (1st code). In all configuration settings it returns "server.name.com" – Ante Jan 05 '12 at 00:56

1 Answers1

1

The web.config transformation is only perform during the publish process. You can still enable it on every build, when you it F5, see

It's an MSBuild task to add.

moi_meme
  • 9,180
  • 4
  • 44
  • 63
  • Interesting! So how can I ensure that different developers can put their own settings in a way that not messes up with source control? – Ante Jan 05 '12 at 01:08
  • 1
    @Ante B. You could, see [Visual studio 2010 - Per Developer/machine/environment Web.Config settings](http://stackoverflow.com/questions/5953666/visual-studio-2010-per-developer-machine-environment-web-config-settings), – moi_meme Jan 05 '12 at 03:38