我正在尝试修改我的 app.config 文件
我正在尝试删除/添加新的 ServiceEndPoint(Requireemnt 是更改端点地址的能力)
我的服务
class SVNServerUIService : ISVNServerUIService
{
public string SetServerData(int portNumber)
{
var clientSection = ConfigurationManager.GetSection("system.serviceModel/services") as ServicesSection ;
var endpoint2 = new ServiceEndpointElement
(new Uri("http://localhost:64445/SVNServerUIService"),
"SVNManagementService.ISVNServerUIService");
//This line is giving Error
clientSection.Services["SVNManagementService.SVNServerUIService"].Endpoints.RemoveAt(1);
clientSection.Services["SVNManagementService.SVNServerUIService"].Endpoints.Add(endpoint2);
clientSection.CurrentConfiguration.Save();
return clientSection.Services["SVNManagementService.SVNServerUIService"].Endpoints[1].Address.ToString();
}
public ClientCompositeType GetDataUsingDataContract(ClientCompositeType composite)
{
throw new NotImplementedException();
}
}
应用程序配置
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpSecuredBinding">
<security mode="Transport">
<message clientCredentialType="Certificate" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="behaviorMetadata" name="SVNManagementService.SVNClientUIService">
<endpoint address="http://localhost:8888/SVNClientService" binding="basicHttpBinding"
name="basicHttpEndPoint" contract="SVNManagementService.ISVNClientUIService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:8889/SVNService/mextcp"
binding="mexTcpBinding" name="mexTcpEndPoint" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/SVNManagementService/Service1/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="behaviorMetadata" name="SVNManagementService.SVNServerUIService">
<endpoint address="http://localhost:9998/SVNServerService" binding="basicHttpBinding"
name="basicHttpEndPoint" contract="SVNManagementService.ISVNServerUIService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:9997/SVNService/mextcp"
binding="mexTcpBinding" name="mexTcpEndPoint" contract="IMetadataExchange" />
<host>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="behaviorMetadata">
<serviceMetadata httpGetEnabled="false" httpGetUrl="http://localhost:8888/SVNService/metadata"
httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
如何在 app.config 中更改服务的地址,然后保存。