views:

323

answers:

1

I am attempting to compile/run a sample WCF application from Juval Lowy's website (author of Programming WCF Services & founder of IDesign). The application is an example of a publish/subscribe 'traffic-light' application that requires using VS 2010/.Net 4. This is my first attempt at using anything other than VS 2008/Net 3.5.

Initially I recieved the following binding error:

"Configuration binding extension 'system.serviceModel/bindings/ netOnewayRelayBinding' could not be found."

This error appeared to be resolved by amending the .Net 4 machine.config file, to incorporate the following references from the .Net 2 machine.config file.

<xml>
<bindingElementExtensions>
 <add name="tcpRelayTransport" type="Microsoft.ServiceBus.Configuration.TcpRelayTransportElement, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 <add name="httpRelayTransport" type="Microsoft.ServiceBus.Configuration.HttpRelayTransportElement, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 <add name="httpsRelayTransport" type="Microsoft.ServiceBus.Configuration.HttpsRelayTransportElement, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 <add name="onewayRelayTransport" type="Microsoft.ServiceBus.Configuration.RelayedOnewayTransportElement, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 <add name="webMessageEncoding" type="System.ServiceModel.Configuration.WebMessageEncodingElement, System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
 <add name="context" type="System.ServiceModel.Configuration.ContextBindingElementExtensionElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
 <add name="byteStreamMessageEncoding" type="System.ServiceModel.Configuration.ByteStreamMessageEncodingElement, System.ServiceModel.Channels, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
 <add name="discoveryClient" type="System.ServiceModel.Discovery.Configuration.DiscoveryClientElement, System.ServiceModel.Discovery, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</bindingElementExtensions>
<bindingExtensions>
 <add name="webHttpBinding" type="System.ServiceModel.Configuration.WebHttpBindingCollectionElement, System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
 <add name="basicHttpContextBinding" type="System.ServiceModel.Configuration.BasicHttpContextBindingCollectionElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
 <add name="basicHttpRelayBinding" type="Microsoft.ServiceBus.Configuration.BasicHttpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 <add name="webHttpRelayBinding" type="Microsoft.ServiceBus.Configuration.WebHttpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 <add name="ws2007HttpRelayBinding" type="Microsoft.ServiceBus.Configuration.WS2007HttpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 <add name="netTcpRelayBinding" type="Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 <add name="netOnewayRelayBinding" type="Microsoft.ServiceBus.Configuration.NetOnewayRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 <add name="netEventRelayBinding" type="Microsoft.ServiceBus.Configuration.NetEventRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
 <add name="wsHttpContextBinding" type="System.ServiceModel.Configuration.WSHttpContextBindingCollectionElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
 <add name="netTcpContextBinding" type="System.ServiceModel.Configuration.NetTcpContextBindingCollectionElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</bindingExtensions>

Unfortunately running the application results in the following security error:

An error occurred creating the configuration section handler for system.serviceModel/client: That assembly does not allow partially trusted callers.
(\TrafficLights\TrafficController\bin\Debug\TrafficController.vshost.exe.Config line 4)

The sample source code is available for download at the following link: http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=-1&amp;tabid=19&amp;download=226

I know that Juval's code is not at fault here and that it must be something I'm doing wrong with my VS 2010 configuration. I have not been able to find a solution online. Could someone please steer me in the right direction as to how best to deal with this issue?

+1  A: 

You are aware that the netOnewayRelayBinding is a Windows Azure related binding, right? In order to use it, you need to use a Azure ServiceBus infrastructure, and you need an account on Windows Azure for that. Just checking....

For one thing, you most likely need the updated Windows Azure Tools for Visual Studio 1.2 in order to make this work with VS 2010.

marc_s
Marc - That would be no - I didn't know that I needed an account on Windows Azure (said somewhat embarrased). As I mentioned in my e-mail, this was my first foray into VS 2010 and WCF didn't seem such a significant 'reach' in VS 2008. I guess it's time to purchase a 2010 WCF reference book. Thanks for your help Marc.Bill
Bill
@Bill: I think Juval also has a version of that traffic light app that works with netTcpBinding or something - something you can handle locally, in your LAN, without Azure...
marc_s
Thank you Marc.
Bill
@Bill: You can just add the reference to the Microsoft.Servicebus.dll and the project will compile. You won't actually need Azure for most of the examples. Also, you will need to be careful because most of the iDesign examples include some version of the ServiceModelEx. If you unzip the downloads in the wrong order, you may have some issues.
Scott P
Thank you Scott.
Bill