MEF 和 WCF - AppDomain 问题

发布于 2024-08-15 03:47:45 字数 281 浏览 2 评论 0原文

我当前正在运行最新的预览版 (#8),并且正在使用 WCF 服务。我使用 MEF 读取 WCF 服务库。我注意到,每当我从读取库的应用程序对其中一个库执行任何操作时,这些 WCF 库的 AppDomain 为 1,但是每当 WCF 服务收到通知时,它的 AppDomain 为 2?有没有一种方法可以确保收到通知的 WCF 服务与通过 MEF 读入的服务相同(或在同一 AppDomain 中)?

我基本上需要读取 WCF 服务上的配置数据,并确保数据始终存储在内存中,以便当收到任何通知时,我使用内存中的数据来帮助分析发送的内容。

I am currently running the latest preview (#8) and I am working with WCF services. I use MEF to read in the WCF Service Libraries. I have noticed that whenever I do any operation on one of the libraries from the application that read in the libraries, those WCF libraries have an AppDomain of 1, but whenever a WCF Service gets a notification, it has an AppDomain of 2? Is there a way to ensure that the WCF Service that gets notified is the same (or in the same AppDomain) as the one that was read in via MEF?

I basically need to read in configuration data on my WCF Service and ensure that the data is always stored in memory so when any notification comes in, that I am use the data in memory to help analyze what was sent in.

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

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

发布评论

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

评论(1

兔姬 2024-08-22 03:47:45

我想通了。我只需要让我的应用程序通过 MEF 读取 DLL 来告诉 DLL 作为服务主机。唯一的缺点是 DLL 必须告诉应用程序要使用的所有绑定和端点,以便应用程序可以设置正确的服务主机。

这是我所做的示例(只是为了使其工作,它没有向 DLL 请求设置的代码):

foreach (MYINTERFACE mod in this.Modules) 
{
    ServiceHost serviceHost = new ServiceHost(
        mod, new Uri[] { new Uri("BINDING URL") });
    var binding = new NetTcpBinding();
    binding.Security.Mode = SecurityMode.None;
    var serviceEndpoint = serviceHost.AddServiceEndpoint(
        typeof(ENDPOINT TYPE), binding, "");
    serviceHost.Open();
    this.ServiceHosts = new List<ServiceHost>();
    this.ServiceHosts.Add(serviceHost);
}

I figured it out. I just need to have my app that is reading in the DLLs via MEF to tell the DLL to be a service host. Only downside to this is the DLL will have to tell the application all the bindings and end-points to use so the application can set up the proper service host.

Here is a sample of what I did (just to make it work, it doesn't have the code to ask the DLL for the setup):

foreach (MYINTERFACE mod in this.Modules) 
{
    ServiceHost serviceHost = new ServiceHost(
        mod, new Uri[] { new Uri("BINDING URL") });
    var binding = new NetTcpBinding();
    binding.Security.Mode = SecurityMode.None;
    var serviceEndpoint = serviceHost.AddServiceEndpoint(
        typeof(ENDPOINT TYPE), binding, "");
    serviceHost.Open();
    this.ServiceHosts = new List<ServiceHost>();
    this.ServiceHosts.Add(serviceHost);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文