【问题标题】:Having NServiceBus messages in Portable Class Library PCL在可移植类库 PCL 中有 NServiceBus 消息
【发布时间】:2015-08-26 09:05:42
【问题描述】:

有没有办法用 NServiceBus 消息创建一个 PCL(就像你可以为 ServiceStack 一样)?我尝试添加 NuGet 包,但似乎不支持 Xamarin

Install-Package NServiceBus

Install failed. Rolling back...
Package 'NServiceBus 5.2.5' does not exist in project 'RZ.Services.ServiceModel'
Install-Package : Could not install package 'NServiceBus 5.2.5'. You are trying to install this package into a project that targets     '.NETPortable,Version=v4.5,Profile=Profile7', but the package does not contain     any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:16
+ Install-Package <<<<  NServiceBus
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId :     NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

未来计划是否有任何变通方案来支持这一点?我们确实永远不会在其他平台上使用 NServiceBus,但我们可能希望同时使用 NServiceBus 和 ServiceStack 来支持不同的场景,因为它们将共享消息,所以必须将它们放在一个类库中。

【问题讨论】:

    标签: servicestack nservicebus portable-class-library


    【解决方案1】:

    最好不要为您的消息引用 NServiceBus,最好使用不显眼的模式

    在此处查看文档:http://docs.particular.net/nservicebus/messaging/unobtrusive-mode

    这确保您的消息不必从任何 NServiceBus 标记接口继承。

    要配置不显眼的模式,请参阅以下部分从文档中复制的示例:

    BusConfiguration busConfiguration = new BusConfiguration();
    ConventionsBuilder conventions = busConfiguration.Conventions();
    conventions.DefiningCommandsAs(t => t.Namespace != null && t.Namespace == "MyNamespace" && t.Namespace.EndsWith("Commands"));
    conventions.DefiningEventsAs(t => t.Namespace != null && t.Namespace == "MyNamespace" && t.Namespace.EndsWith("Events"));
    conventions.DefiningMessagesAs(t => t.Namespace != null && t.Namespace == "Messages");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-06
      • 2013-12-14
      • 1970-01-01
      • 1970-01-01
      • 2014-03-19
      • 2016-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多