我有一个项目是使用netTCP端点的WCF客户端。该项目编译成另一个项目引用的DLL。我使用的AppSettings像这样的本地和远程IP端点之间进行切换:App.config AppSettings返回null
public EmbeddedClient()
{
//Grab ip to use: remote or local (used for simulator)
String location = ConfigurationSettings.AppSettings["ipAddress"];
String ip = ConfigurationSettings.AppSettings[location];
//Default to localhost if no appsetting was found
if (ip == null)
ip = "localhost";
String address = String.Format("net.tcp://{0}:9292/EmbeddedService", ip);
//Setup the channel to the service...
channelFactory = new ChannelFactory<IEmbeddedService>(binding, new EndpointAddress(address));
}
我App.Config中是我有我的AppSettings和WCF端点:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ipAddress" value="local"/>
<!-- Replace above value to "local" (Simulator) or "remote" (Harware)-->
<add key="local" value="localhost"/>
<add key="remote" value="192.168.100.42"/>
</appSettings>
<system.serviceModel>
<!--WCF Endpoints go here--->
</system.serviceModel>
</configuration>
当我编译该项目appsetting总是返回null。我还注意到,编译后,app.config被重命名为Embedded_DCC_Client.dll.config。为什么它无法找到我的appsettings?为什么它返回null?谢谢。
,你能否告诉有关(配置)文件的文件夹? –