简体   繁体   English

Windows服务中的Web服务参考问题

[英]Web service reference problem in Windows service

I have a Windows Service which runs a Web Service code in a library. 我有一个Windows服务,该服务在库中运行Web服务代码。 The structure is like this: 结构是这样的:

MyWindowsService.exe (references to MyServiceLibrary.dll)
MyWindowsService.exe.config
MyServiceLibrary.dll (references to web service)
MyServiceLibrary.dll.config (contains endpoint information about the web service)

The process is like this: 过程是这样的:

MyWindowsService calls MyServiceLibrary.Method()
MyServiceLibrary.Method() calls WebService.Method()

The problem is I'm getting an error about not able to find any endpoints for MyServiceLibrary unless I add information to MyWindowsService.exe.config too. 问题是,除非我也向MyWindowsService.exe.config添加信息,否则我将收到有关无法找到MyServiceLibrary的任何终结点的错误。 Is there a way to prevent this? 有办法防止这种情况吗? I'd like keep config files seperate from each other if possible. 如果可能,我希望将配置文件彼此分开。

The configuration in MyServiceLibrary.dll.config is not getting loaded. MyServiceLibrary.dll.config中的配置未加载。 Move the web service endpoint configuration into MyService.exe.config. 将Web服务端点配置移到MyService.exe.config。

Do you mean for your Windows Service to call the web service? 您是要Windows服务调用Web服务吗? If that's the case, then the Windows service should not reference the web service assembly (DLL). 如果是这种情况,则Windows服务不应引用Web服务程序集(DLL)。 Instead, you should add a Service Reference to the Windows Service project, pointing to where the web service is hosted. 相反,您应该将服务引用添加到Windows Service项目,并指向Web服务的托管位置。 Then, the Windows Service is just another client of the web service. 然后,Windows服务只是Web服务的另一个客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM