简体   繁体   English

NService总线和GAC

[英]NService bus and the GAC

I have recently tried to migrate the NServiceBus libraries to the GAC as they are pretty big and are required in nearly all of my software. 我最近尝试将NServiceBus库迁移到GAC,因为它们很大,几乎是我所有软件中都需要的。 I am using the newest .NET 4.0 Build (2.0.0.1219) and have used GACUTIL to copy NServiceBus & NServiceBus.Core into the new GAC and log4net into the old 2.0 GAC. 我正在使用最新的.NET 4.0 Build(2.0.0.1219),并已使用GACUTIL将NServiceBus和NServiceBus.Core复制到新的GAC中,并将log4net复制到旧的2.0 GAC中。 I have managed to get log4net working by wiring in the version and PublicKeyToken but I cannot get the NServiceBus.Core working. 我已经通过连接版本和PublicKeyToken设法使log4net工作,但是我无法使NServiceBus.Core工作。 Every time I start a piece of software I get the following error: 每次我启动一个软件时,都会出现以下错误:

"Type NServiceBus.Unicast.Transport.CompletionMessage was not registered in the serializer. Check that it appears in the list of configured assemblies/types to scan." “类型NServiceBus.Unicast.Transport.CompletionMessage未在串行器中注册。请检查它是否出现在要扫描的已配置程序集/类型列表中。”

When I copy the DLL NServiceBus.Core to the local folder it works fine. 当我将DLL NServiceBus.Core复制到本地文件夹时,它可以正常工作。

my config looks like this: 我的配置看起来像这样:

<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core, Version=2.0.0.1219, Culture=neutral, PublicKeyToken=9fc386479f8a226c" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core, Version=2.0.0.1219, Culture=neutral, PublicKeyToken=9fc386479f8a226c" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" />
<sectionGroup name="common">
  <section name="logging" type="Common.Logging.ConfigurationSectionHandler, NServiceBus.Core, Version=2.0.0.1219, Culture=neutral, PublicKeyToken=9fc386479f8a226c"/>
</sectionGroup>

So i'm wondering has anyone else got NServiceBus successfully working with the GAC? 所以我想知道是否还有其他人使NServiceBus与GAC成功合作?

Cheers 干杯

It is an issue with NServiceBus stripping strong names. NServiceBus剥离强名称是一个问题。 Use the <runtime> element in web.config : 使用web.config<runtime>元素:

<runtime>
    <qualifyAssembly partialName="MessagesDll" fullName="MessagesDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4d476a51357cea5c" />

NServiceBus scans the assemblies in a directory (the run directory for an application, the website's compiled directory for a web application) in order to load all the message handlers, and that means it needs to scan itself as well for all the types it needs for dependency injection. NServiceBus扫描目录中的程序集(应用程序的运行目录,Web应用程序的网站的编译目录)以便加载所有消息处理程序,这意味着它需要同时扫描自身以及所需的所有类型。依赖注入。

I'm not sure that this model supports assemblies living in the GAC by default, although if you're configuring NServiceBus yourself, you can specify the assemblies to load yourself through the NServiceBus.Configure.With(params Assembly[] assemblies) overload, just make sure to include all the NServiceBus assemblies and Log4Net at the very least. 我不确定默认情况下该模型是否支持GAC中存在的程序集,尽管如果您自己配置NServiceBus,则可以指定程序集通过NServiceBus.Configure.With(params Assembly [] assembly)重载来加载自己,只要确保至少包括所有NServiceBus程序集和Log4Net。

However, I would contend that GAC-ing the NSB assemblies might not be the best idea. 但是,我认为将GAC引入NSB程序集可能不是最好的主意。 Each endpoint having its own copy of the assembly reinforces the autonomy of the endpoints, and will make it much easier if you ever need to upgrade to a new version of NServiceBus, since you would be able to test each endpoint individually and not just put a new assembly in the GAC, add a binding redirect, and hope everything continues to run fine. 每个端点都有自己的程序集副本,可以增强端点的自治性,并且如果您需要升级到新版本的NServiceBus,将使其更加容易,因为您将能够单独测试每个端点,而不仅仅是放置一个端点。 GAC中的新程序集,添加绑定重定向,并希望一切继续正常进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM