2015-12-04 25 views
0

我有一個C#VSTO Word AddIn從中我成功地進行WCF服務調用。我現在試圖從AddIn中動態替換配置文件(我的AddIn的基本目錄中的MyAddin.dll.config),以便我可以重定向到其他端點。一旦我把文件的變化,我使用此代碼刷新:不從動態交換配置信息從VSTO調用的WCF服務Word AddIn

System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); 
ConfigurationManager.RefreshSection("appSettings"); 
ConfigurationManager.RefreshSection("system.serviceModel/behaviors"); 
ConfigurationManager.RefreshSection("system.serviceModel/bindings"); 
ConfigurationManager.RefreshSection("system.serviceModel/client"); 
ConfigurationManager.RefreshSection("system.serviceModel/services"); 

我沒有當我這樣做的任何WCF客戶端打開。此刷新後,當我馬上創建一個新的客戶端

var adminProxy = new CorrespondenceAdminClient(); 
mcRibbon.serviceHostUri = adminProxy.Endpoint.Address.Uri.ToString(); 

它似乎已經拿起了新的信息,但是當我調用服務的方法,有時呼叫被引導到正確的端點,有時不是。當我隨後創建一個客戶端並從我的AddIn代碼的另一部分調用一個服務時,它又可能會或可能不會到達預期的端點。有時即時通話有效,但後續通話不會。

此信息是否緩存在某處?我可以清除它嗎?

我已經試過從Visual Studio(Premium 2012)調試器內部和外部運行這個,這並沒有什麼區別。

回答