WCF扩展,而不包括程序集版本而不、版本、程序、WCF

2023-09-03 10:12:32 作者:活得如此颓废

由于这里讨论,我尝试添加WCF终结扩展;我有工作,但我需要包括完整的装配细节:

As discussed here, I'm trying to add a WCF endpoint-extension; I've got it working, but I need to include the full assembly details:

<extensions>
    <behaviorExtensions>
        <add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=1.0.0.275, Culture=neutral, PublicKeyToken=257b51d87d2e4d67"/>
    </behaviorExtensions>
</extensions>

我会的喜欢的做(在更新时等,尤其对样品避免的问题)是仅包括名称:

What I would like to do (to avoid issues when updating etc, especially for samples) is to include just the names:

<add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net"/>

(这是你所期待的标准组件,命名约定)

(which is what you might expect from standard assembly-naming conventions)

但是,如果我这样做,我得到一个很大的错误:

However, if I do this, I get a big error:

分析器错误信息:发生创造system.serviceModel /行为的配置节处理错误:无法加入到这一元素扩展元素的protobuf。验证扩展在system.serviceModel /扩展/ behaviorExtensions注册的扩展集。

Parser Error Message: An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'protobuf' cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions.

难道的可能的(如果是的话:怎么样)?添加一个扩展,而无需指定程序集版本

Is it possible (and if so: how) to add an extension without having to specify the assembly-version?

推荐答案

AFAIK,这是不幸的是没有可能在behaviorExtensions部分使用部分的名称。奇怪的是,这只是为behaviorExtensions部分。例如,你可以做bindingElementExtensions不完整的程序集名称。看起来就像谁写的配置部分实现并没有允许部分名称装载在那里同样的看法。我没有检查,看看这是纠正在.NET 4呢。

AFAIK, it's unfortunately not possible to use partial names in the behaviorExtensions section. Strangely enough it's only for the behaviorExtensions section. For example, you can do bindingElementExtensions without full assembly name. Just looks like whoever wrote that configuration section implementation didn't allow for partial name loading where as the others did. I haven't checked to see if this is remedied in .NET 4 yet.