从远程 DLL 调用 WCF 服务

发布于 2024-08-09 12:17:17 字数 664 浏览 4 评论 0原文

我有一个进程,我们称之为进程 A,它托管一个通过基本 Http 绑定公开的简单 WCF 服务。如果我启动该进程,我就可以从另一个进程(进程 B)访问该服务,没有任何问题。

然而,我所需的用例并不那么简单。我需要做的是从远程托管的 DLL 访问服务。远程 DLL 由进程 A 在单独的 AppDomain 中启动,并且位于本地计算机上。

当我从进程 A 调用远程 DLL 中的方法时,该方法又应该回调进程 A 中托管的 WCF 服务,调用者只是挂起,一分钟后我得到服务超时。永远不会输入服务代码(永远不会到达外部调用它时遇到的断点)。

远程 DLL 能够创建客户端代理类的实例这一事实告诉我(如果我错了,请纠正我)该服务的配置至少在远程客户端中可用。如果我删除服务引用,它不会抱怨缺少配置信息或抛出异常,就像在外部客户端中那样。

所以我想我的问题是多部分的。首先,远程 DLL 能否首先调用 WCF 服务(即客户端是否可以使用所有必需的基础结构)?如果可以的话,我可能会错过什么?如何调试这样的事情呢?当这是一个简单的情况时,调试远程处理是很痛苦的 - 而这并不那么简单。

最后一件事 - 我无法改变这样一个事实:我正处于远程 DLL 的进程中,并且远程 DLL 需要使用该服务。它是该应用程序基础架构中根深蒂固的一部分。但是,如果有任何用处,我可以将大多数 WCF 服务托管到另一个进程(并且我可能会在此处等待任何答案时尝试这样做)。

I have a process, let's call it Process A, that is hosting a simple WCF service exposed though a basic Http binding. If I spin up that process I can then access the service from another process, Process B, with no problems.

However, my required use case isn't so simple. What I need to do is access the Service from a DLL that is hosting with Remoting. The Remoted DLL is spun up in a separate AppDomain by Process A and it is on the local machine.

When I call a method in the remoted DLL from Process A which in turn is supposed to call back to the WCF Service hosted in Process A the caller just hangs and after one minute I get a service timeout. The service code is never entered (a breakpoint that gets hit when calling it externally never is reached).

The fact that the Remoted DLL is able to create an instance of the client proxy class tells me (correct me if I'm wron here) that the configuration for the service is at least available in the Remoted client. It doesn't complain about missing configuration info or throw an exception like it does in the external client if I remove the service reference.

So I guess my question is multi-part. First, can a Remoted DLL call a WCF service in the first place (i.e. is all of the requisite infrastructure available to the client)? If it can, what might I be missing? And how does one go about debugging something like this? Debugging remoting is painful when it's a simple case - and this is not so simple.

One last thing - I can't change the fact that I'm in a process that is remoting the DLL and that remoted DLL needs to consume the service. It's a deeply entrenched part of the infrastructure of this app. I could, however, most the WCF service host to another process if it is of any use (and I might try that while waiting for any answers here).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尴尬癌患者 2024-08-16 12:17:17

远程 DLL 能够创建客户端代理类的实例这一事实并不意味着配置就可以了。

确保您使用与服务器相同的基地址、相同的协议和安全模式。

由于您在同一台计算机上,因此不应该出现网络问题。

The fact that the Remoted DLL is able to create an instance of the client proxy class doesn't sais that configuration is ok.

make sure you use the same base address as the server uses, and the same protocol, and security mode.

since you're on the same machine there should not be networking problem.

神妖 2024-08-16 12:17:17

最后我们完全删除了Remoting。虽然工作量很大,但这是正确的做法。

In the end we removed Remoting copmpletely. It was a lot more work, but was the right thing to do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文