Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not sure if this is still an issue for you but perhaps the answer will help others.</p> <ol> <li><p>To use your binding via .config, you need to create a class which extends BindingCollectionElement</p> <pre><code>public class MyCustomBindingCollectionElement : BindingCollectionElement { public override Type BindingType { get { return typeof(MyCustomBinding); } } public override ReadOnlyCollection&lt;IBindingConfigurationElement&gt; ConfiguredBindings { get { return new ReadOnlyCollection&lt;IBindingConfigurationElement&gt;( new List&lt;IBindingConfigurationElement&gt;()); } } public override bool ContainsKey(string name) { // HACK!!! return true; //throw new NotImplementedException(); } protected override System.ServiceModel.Channels.Binding GetDefault() { return new MyCustomBinding(); } protected override bool TryAdd(string name, System.ServiceModel.Channels.Binding binding, Configuration config) { throw new NotImplementedException(); } } </code></pre></li> <li><p>Put your binding and BindingCollectionElement, eg 'MyBinding', in a Class Library and compile into an Assembly, eg called 'ServiceLib'.</p></li> </ol> <p>Then add a reference to that assembly from my WCF Hosted Site - do this via right-click in VS2010 > Add Reference (then browse to 'bin' folder of the Class Library project mentioned above and select the 'ServiceLib' DLL).</p> <p>Now that your WCF Website knows about the ServiceLib.dll, you can add a BindingExtension to the Service. You can do this with the WCF Config. Editor dialog or directly add the following to your web.config:</p> <pre><code>&lt;system.serviceModel&gt; ... &lt;extensions&gt; &lt;bindingExtensions&gt; &lt;add name="MyCustomBinding" type="MyCustomBindingCollectionElement, ServiceLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/&gt; &lt;/bindingExtensions&gt; &lt;/extensions&gt; ... &lt;/system.serviceModel&gt; </code></pre> <p>You then use the binding in an endpoint of your service as such:</p> <pre><code>&lt;services&gt; &lt;service name="MyService"&gt; &lt;endpoint address="" binding="MyCustomBinding" name="MyCustomBindingEndpoint" contract="IMyService" /&gt; &lt;/service&gt; &lt;/services&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload