第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

C# 如何在運行時更新 Visual Studio 2107 xxx.exe.config 綁定?

C# 如何在運行時更新 Visual Studio 2107 xxx.exe.config 綁定?

C#
桃花長相依 2021-06-29 13:48:12
當(dāng)我編譯我的 C# web 服務(wù)代碼時,會創(chuàng)建一個 xxx.exe.config 文件。但是,我想在運行時修改其中一個綁定。Visual Studio 生成的 xxx.exe.config 文件的示例是:<?xml version="1.0" encoding="utf-8" ?><configuration>    <system.serviceModel>        <bindings>            <basicHttpBinding>                <binding name="BasicHttpBinding_ContentService"                         messageEncoding="Mtom" />            </basicHttpBinding>        </bindings>    </system.serviceModel></configuration>我想在運行時向名為“BasicHttpBinding_ContentService”的綁定添加一些參數(shù),相當(dāng)于手動編碼:<binding name="BasicHttpBinding_ContentService"                                           messageEncoding="Mtom"              maxBufferSize="5000000"              maxBufferPoolSize="524288"              maxReceivedMessageSize="2147483648"              transferMode="Streamed" />我認(rèn)為定義參數(shù)設(shè)置的 C# 代碼如下所示:using System.ServiceModel;BasicHttpBinding myBinding = new BasicHttpBinding("BasicHttpBinding_ContentService");myBinding.MaxBufferSize = 5000000;myBinding.MaxBufferPoolSize = 524288;myBinding.MaxReceivedMessageSize = 2147483648;myBinding.TransferMode = TransferMode.Streamed;但是我找不到將“myBinding”應(yīng)用于我的 Visual Studio .config 文件的 C# 示例(有效)。我確實找到了在我的環(huán)境中未定義的參考類,如 ServiceHost 和 ServiceClient。注意 - 我使用的是 .NET 4.6。
查看完整描述

2 回答

?
墨色風(fēng)雨

TA貢獻(xiàn)1853條經(jīng)驗 獲得超6個贊

嘗試這樣的事情,讓我知道......


NTEGRAWSSOAPClient _wsProtheus = null; // NTEGRAWSSOAPClient is a SOAP client class generated by vs2017 on register webservice


var endpointConfiguration = NTEGRAWSSOAPClient.EndpointConfiguration.INTEGRAWSSOAP; //INTEGRAWSSOAP is a ConfigurationName of service


_wsProtheus = new NTEGRAWSSOAPClient(endpointConfiguration,new EndpointAddress("http://new address?wsdl", new SpnEndpointIdentity("your identi")));


BasicHttpBinding bind = (BasicHttpBinding)_wsProtheus.Endpoint.Binding;


bind.CloseTimeout = TimeSpan.Parse("02:00:00");

bind.OpenTimeout = TimeSpan.Parse("02:00:00");

bind.ReceiveTimeout = TimeSpan.Parse("02:00:00");

bind.SendTimeout = TimeSpan.Parse("02:00:00");

bind.MaxBufferPoolSize = Int32.MaxValue;

bind.MaxBufferSize = Int32.MaxValue;

bind.MaxReceivedMessageSize = Int32.MaxValue;


bind.ReaderQuotas.MaxDepth = 32;

bind.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;

bind.ReaderQuotas.MaxArrayLength = Int32.MaxValue;

bind.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue;

bind.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue;


bind.Security.Mode = BasicHttpSecurityMode.None;


查看完整回答
反對 回復(fù) 2021-07-10
  • 2 回答
  • 0 關(guān)注
  • 145 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號