我有一个实现 Windows 服务业务逻辑的 WCF 类库。在app.config
文件中,我定义了一个名为“调试模式”的属性,用于调试目的。
然后我创建了单独的 Windows 服务,并在上面创建了 WCF 类库作为参考(通过添加.dll文件和“使用名称”语句)。
app.config我需要使用 Windows 服务文件在 wcf 类库文件中设置“调试模式”属性app.config。
可能吗 ?还是我有任何替代方法。
我有一个实现 Windows 服务业务逻辑的 WCF 类库。在app.config
文件中,我定义了一个名为“调试模式”的属性,用于调试目的。
然后我创建了单独的 Windows 服务,并在上面创建了 WCF 类库作为参考(通过添加.dll文件和“使用名称”语句)。
app.config我需要使用 Windows 服务文件在 wcf 类库文件中设置“调试模式”属性app.config。
可能吗 ?还是我有任何替代方法。
If you are using appSettings and ConfigurationManager to read your property, you have to put (copy - as @JohnSounders explaine) your property into your windows service config file.
In other case - you'll not be able to retrieve it from config.
In usual way, your application will look for configuration of current running executable (in your case - windows service).
您应该能够拥有一个 app.config,并且 WCF 库和 Windows 服务都可以从中读取。Windows 服务是当前线程并引用 WCF 库,因此 WCF 库可以访问 Windows 服务的 app.config。