开发者

MEF and WCF - Issues with AppDomain

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 whe开发者_Go百科n any notification comes in, that I am use the data in memory to help analyze what was sent in.


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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜