How To Transfer App.Config ApplicationSettings to Web.config

Add Web Reference from a class library for .Net 2.0

If you still use .Net framework 2.0, the way to reference a web service to your project is to add a Web Reference.
What if you want to add the web reference from a class library project? This will result to Visual Studio automatically
adding an app.config to your project. The app.config will contain the configuration under applicationSettings of the newly added reference of the web service.

Add Web Reference - ApplicationSettings

Add Web Reference

The app.config will look like this for example.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Noel.Sample.ServiceInterface.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<Noel.Sample.ServiceInterface.Properties.Settings>
<setting name="Noel_Sample_ServiceInterface_ServiceHello_Service"
serializeAs="String">
<value>http://localhost:59962/Service.asmx</value>
</setting>
</Noel.Sample.ServiceInterface.Properties.Settings>
</applicationSettings>
</configuration>

What if you want to use one config file?

Your main application is a web application and it has its own web.config file. What if you want to use and maintain one
config file? You don’t need to point the app.config section from your web.config file. You can move the section group and
the section of the web service from your app.config to your web.config.

Move app.config applicationSettings to Web.config

<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework,
Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Noel.Sample.ServiceInterface.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<Noel.Sample.ServiceInterface.Properties.Settings>
<setting name="Noel_Sample_ServiceInterface_ServiceHello_Service"
serializeAs="String">
<value>http://localhost:59962/Service.asmx</value>
</setting>
</Noel.Sample.ServiceInterface.Properties.Settings>
</applicationSettings>
</configuration>

The section group can be added to the configSections. The applicationSettings can be added under the configuration section of the web.config.

Get value of service URL from Web.Config under applicationSettings

Under appSettings of a Web.config file usually you use for example ConfigurationManager.AppSettings[“WebServiceURL”] to get a value in the Web.config. But when the URL is under the applicationSettings in a Web.config this is how you can get the value of the URL.

public class ConfigHelper
{
public string GetUrl()
{
var section = (ClientSettingsSection)ConfigurationManager.
GetSection("applicationSettings/Noel.Sample.ServiceInterface.Properties.Settings");
var url = section.Settings.Get("Noel_Sample_ServiceInterface_ServiceHello_Service").Value.ValueXml.InnerText;
return url;
}

}

The last step is to remove the app.config from the class library. This is the case if the app.config was added to have the configuration of the web reference. In other cases where you need to the app.config, just remove the configSections and applicationSettings for the web service.

I spent some time looking for a way to make this work and not too much resource from web points to this approach. Hopefully it can help solving yours in less time. Thank you for this post from Stackoverflow on how solve this problem.

Comments

  1. この度は迅速な発送と丁寧な梱包でありがとう
    ございました。
    そして商品についても予想以上にきれいな物で嬉しい驚きでした
    ★グッチ グッチ★ジャッキーバッグ★セミショルダーバッグ★00963★GGデニム×カーフ★ブラック/黒★
    こんなお値段だし・・・とたいした期待は持たずに購入したのですが、良い意味での期待を大
    きく裏切るような綺麗な商品が届いて驚きました。
    バックもお財布も早速活用しています。
    かなりお買い得気分です。
    また利用したいと思います。
    ありがとうございました。
    スーパーコピー ヴィトン マフラー https://www.kopijp.com/product/detail-10167.html

  2. N級バッグ、財布、腕時計 専門サイト問屋

    弊社は販売ルイヴィトンコピー、エルメスコピー、シャネルコピー、グッチコピー、ロレックスコピー、 バッグ、財布、 小物、腕時計、靴類などでございます。
    弊社は「信用第一」をモットーにお客様にご満足頂けるよう、
    発送前には厳しい検査を通じて製品の品質を保証してあげますとともに、
    配送の費用も無料とし、品質による返送、交換、さらに返金までも実際 にさせていただきます。
    また、従業員一同、親切、丁寧、迅速に対応 させて頂き、ご安心になってお買い物を楽しんでくださるよう精一杯力 を尽くしていくつもりです。

    送料は無料です(日本全国)! ご注文を期待しています! 下記の連絡先までお問い合わせください。

    是非ご覧ください!
    ロレックス 安い 時計 https://www.2bcopy.com/product/product.aspx-id=1110.htm

  3. SALEが開催中

    当店は世界最高級ブランドスーパーコピーを大勢揃っています。
    スーパーコピールイヴィトンをはじめ、クロエ、グッチ、シャネル、ミュウミュウなど、
    様々な海外有名なブランドコピーバッグや財布等を販売しております。
    今、いろいろブランドコピー新品が登場します。
    バッグ、財布、シューズ、小物など逸品がぜひおすすめです。
    ルイ ヴィトン ランキング dvd https://www.2bcopy.com/www.japan567.com/menu/menu_pinpai.aspx-id=71

  4. 配送、梱包とても良かったです。対応の早さもあり商品を早く手に入れる事が出来助かりました。
    サマンサベガ 長財布 ラウンドファスナー長財布 ホワイト ブラック ギンガムチェック柄 【訳あり】 新品・未使用 ウォレット 白 黒 120712035 Samantha Vega
    とても満足です。
    初めは少し大きめかな~?との心配も有りましたがそんなこともなく
    便利に使っています。大きめに開くことで使い勝手が良く購入して良かったです。
    ロレックス オイスター 相場 https://www.88kopi.com/menu/menu-p-4-pid-47.html

  5. 激安なヴィトンコピー通販店
    品質が秀逸で値段が激安なヴィトンコピー通販店
    海外安心と信頼のルイ・ヴィトンコピー
    業内最高レベルのスーパーコピーブランド
    正規品と同等品質の超人気などの商品や情報が満載!
    品質が秀逸&H44値段が激安!
    今、いろいろルイ・ヴィトン コピー2022春夏新品が続々登場します。
    爆安SALEも開催.。
    ルイ ヴィトン レプリカ full https://www.buykopi78.com/product/ProductShow-4781.html

  6. ルイヴィトン – N級バッグ、財布 専門サイト問屋
    弊社は販売バッグ、財布、 小物、靴類などでございます。
    1.当社の目標は品質第一、信用第一、ユーザー第一の原則を守り、心地よい親切で最高のインターネットサービスご提供することです。
    2.品質を重視、納期も厳守、信用第一は当社の方針です。
    3.弊社長年の豊富な経験と実績があり。輸入手続も一切は弊社におまかせてください。質が一番、最も合理的な価格の商品をお届けいたします。
    4.お届け商品がご注文内容と異なっていたり、欠陥があった場合には、全額ご返金、もしくはお取替えをさせていただきます。
    弊社は「信用第一」をモットーにお客様にご満足頂けるよう、
    送料は無料です(日本全国)! ご注文を期待しています!
    下記の連絡先までお問い合わせください。
    是非ご覧ください!
    休業日: 365天受付年中無休
    16710 スーパーコピー https://www.b2kopi.com/product/detail.aspx-id=5417.htm

  7. ルイヴィトンコピー品第1店 販売専門店

    ★真のブランドコピー品質をお届けするルイヴィトンブランドコピー!
    ※価値あるブランドコピー財布、バッグのヴィトンコピー※
    ■品質重視なブランドコピー商品販売!
    ★高級品☆┃時計┃バッグ┃財 布┃その他┃
    ◆★ 誠実★信用★顧客は至上
    ●在庫情報随時更新!
    品質がよい 価格が低い 実物写真 品質を重視
    100%品質保証 100%満足保障 信用第一
    ★人気最新品┃特恵中┃☆腕時計、バッグ、財布、ベルト、靴、帽子、アクセサリー、小物☆
    ★当店商品送料無料日本全国!

    ※全物品激安,到着するのは迅速で、安全。
    ■あなたの訪問のを期待しています!☆ヽ(▽⌒)
    会社名称 ルイヴィトンコピーN品第1店

    ホームページ上でのご注文は24時間受け付けております
    ロレックス オイスター サブマリーナ https://www.gmt78.com/product/detail/13674.htm

  8. ブランドコピーブランド
    弊社は 販売ルイヴィトン、シャネル(シャネル)、グッチ
    (グッチ)、エルメス(エルメス)、D&G カバン、コーチ(COACH)のブランドバッグ、財布、
    小物、腕時計、靴類などでございます。
    弊社は「信用第一」をモットーにお客様にご満足頂けるよう、
    発送前には厳しい検査を通じて製品の品質を保証してあげますとともに、
    配送の費用も無料とし、品質による返送、交換、さらに返金までも実際
    にさせていただきます。
    また、従業員一同、親切、丁寧、迅速に対応
    させて頂き、ご安心になってお買い物を楽しんでくださるよう精一杯力
    を尽くしていくつもりです。
    送料は無料です(日本全国)! ご注文を期待しています!
    下記の連絡先までお問い合わせください。
    是%9RDROFRNCRORAR@RDROFRORDROFRGRDROFRNBRDROFROCVRGRGRDRODRRDROERC\RDRODRCRDROERDRDRODROORDRODRD\RDRODRRDRODRN@RDRODRRDROER\\RCRRDRBRRNBRDROFRO\RDREREYYRERERERENCFDBNAGFDFGY

  9. 高品質コピーブランド通販店
    当店は主に高品質低価格複製品も含め、腕時計、バッグ、財布、マフラー、アクセサリーなど。
    各種のブランドはそろって、在庫情報は随時更新しそして優待価格、品質保証100 %。
    安心してご購入ください!!
    店長お薦めは以下の商品:
    1,フランクミュラー高品質コピー
    2,高品質コピー マフラー各種のブランド偽物(コピー商品)のマフラー
    ★歓迎光臨スーパーコピーブランド高品質店
    スーパーコピー 売る 7つの戦略 https://www.2bcopy.com/product/product.aspx-id=7602.htm

  10. 迅速に対応していただきました。商品状態や配送とも問題なく。良い買い物が出来ました。
    ★グッチ グッチ★グッチシマ★プレートキーホルダー★ブラウン×シルバー色★
    嫁の誕生日に購入しました。手軽でおしゃれだったので購入しました。かわいいととても喜んでました。
    ヤマダ電機 時計 ロレックス https://www.gmt78.com/product/detail/13656.htm

Leave a Reply to https://www.kopijp.com/product/detail-10167.html Cancel reply

*