簡體   English   中英

跳過App.config配置並在C#中進行配置

[英]Skipping App.config configuration and configuring in C#

如果我想從客戶端代碼中刪除app.config配置的必要性,並從c#中初始化客戶端。 在我的C#代碼中定義綁定和EndPoint。 以下客戶端代碼的ac#版本是什么:

<client>
            <endpoint address="http://employeetstsvc/Employee.svc" binding="wsHttpBinding"
                bindingConfiguration="StandardEndpoint" contract="ServiceReference2.IHREmployee"
                name="StandardEndpoint" />
        </client>

有任何想法嗎?

像下面這樣。 在這里查看更多

String baseAddress = "http://employeetstsvc/Employee.svc";

WSHttpBinding binding1 = new WSHttpBinding();

using(ServiceHost host = new ServiceHost(typeof(Employee)))
{
   host.AddServiceEndpoint(typeof(ServiceReference2.IHREmployee),binding1, baseAddress);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM