在WCF服务上使用LoaderOptimizationAttribute [英] Using the LoaderOptimizationAttribute on a WCF service
问题描述
我有一个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属性添加到主机应用程序的main方法中.但是,由于我正在使用服务,因此没有主要方法.
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中托管,则应默认应用"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屋!