在 WCF 服务上使用 LoaderOptimizationAttribute [英] Using the LoaderOptimizationAttribute on a WCF service

查看:20
本文介绍了在 WCF 服务上使用 LoaderOptimizationAttribute的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 wcf 服务,它使用 .net System.AddIns 框架将程序集加载到单独的进程和应用程序域中.为了提高性能,我想启用跨域 FastPath.

I have a wcf service that uses the .net System.AddIns framework to load assemblies into a seperate process and app domain. To improve performance I want to enable the Cross-Domain FastPath.

根据文档,我需要将 LoaderOptimizationAttribute 属性添加到我的宿主应用程序的主要方法中.但是我没有主要方法,因为我正在使用服务.

According to the documentation I need to add the LoaderOptimizationAttribute attribute to the main method of my host application. However I do not have a main method as I am using a service.

那么可以使用属性吗?如果不是,那么我如何确保加载程序集作为域中立加载?

So is it possible to use the attribute? If not then how can I ensure that the addin assemblies are loaded as domain neutral?

谢谢.

推荐答案

如果你在 IIS 中托管,你应该默认应用 gettng "LoaderOptimization(LoaderOptimization.MultiDomainHost)",而且似乎没有办法改变这个我能找到的.如果您想要应用其他东西,您可能需要推出自己的主机(对于 WCF 来说并不难,但肯定不如 IIS 托管方便或功能丰富).

If you are hosting in IIS, you should be gettng "LoaderOptimization(LoaderOptimization.MultiDomainHost)" applied by default, and there seems to be no way to change this that I can find. If you want something else applied, you may need to roll your own host (not that hard for WCF, but certainly not as convenient or feature-rich as IIS hosting).

但是,这应该将所有程序集加载为域中立的 - 所以它可能已经是你想要的了.确保您没有使用 Assembly.LoadFrom(),因为这会使应用程序域无法共享 JIT 代码.

However, this should load all assemblies as domain-neutral - so it is probably what you want already. Make sure you are not using Assembly.LoadFrom(), as this makes it impossible for appdomains to share the JITed code.

这篇关于在 WCF 服务上使用 LoaderOptimizationAttribute的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆