开发者

WCF extensions without including the assembly version

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:

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 a开发者_开发技巧n extension without having to specify the assembly-version?


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.


Have you thought about using the WCF facility for Windsor? It automagically wires extensions to service implementations when they're both registered with the container. Of course, Windsor doesn't require full assembly names. If you're not using Windsor, I'm sure you could fairly easily build an equivalent framework for other IoC containers.


Just to reiterate what @wojo noted. If you have come here looking for the answer to

"cannot be added to this element.  Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions."

and you are now running .Net 4 then REMOVE the assembly Version,Culture,PublicKeyToken from the behaviorExtensions add tag. all that is needed (worked for me) was the full namespace/class followed by the assembly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜