So you’ve just installed the latest Windows Azure SDK 1.3 or you’ve upgraded your Azure 1.2 SDK. You press F5 or run your azure project in the local emulator (previously the ‘local development fabric’) you get the error:
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state
In Visual Studio, it might look like this -
Bummer. But don’t worry, below I have details on how to fix this issue.
How to fix the error: “The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state” when running a Windows Azure project in the local development fabric/emulator
If you click on “View Detail…” you’ll see this exception -
Here’s the full exception -
System.ServiceModel.CommunicationObjectFaultedException was unhandled
Message=The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
Exception rethrown at :
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at Microsoft.WindowsAzure.Hosts.WaIISHost.Program.Main(String args)
There seems to be a bug in the Windows Azure SDK 1.3 that causes this exception to occur if your Web.Config file is read-only. Since many of us use TFS or some other source control system, there’s a high chance your Web.Config is read-only and you will get this error when you run your azure project in the local emulator.
The fix: simply make your Web.Config not read-only. You can manually change the read-only attribute in windows explorer, but when you get the latest from source control, it will be marked as read-only again.
So a better way is to create a post-build event that marks the Web.Config as not read-only right after compilation, but before your project starts running in the local emulator.
Right-click on your ASP.NET site or WCF web service project and choose Properties > Build Events -
In the ‘Post-build event command line’, enter -
attrib -r "$(ProjectDir)Web.Config"
That’s it! Now you can run your windows azure project in the 1.3 emulator and the stupid exception will no longer occur.
Here’s the original thread in the Windows Azure forums, where I found this solution -
Error deploying locally 29 November 2010 Azure Tools