The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

Today was the first time I have worked on our Azure application in quite a while, so I was unpleasantly surprised when I got the latest version of the code, clicked run and was greeted with :

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

CommunicationObjectFaultedException

After a lot of poking around and reinstalling the SDK I finally found the solution.  Apparently when running an application under Azure SDK version 1.3 the development environment needs to modify the web config in some way.  However, since I am using TFS for source control, the file was marked readonly and could not be edited.

The work around seemed pretty simple, just remove the readonly flag and off we go.  The next problem is that every time you get latest from source control the file gets marked readonly again and now it won’t run. 🙁  To get around this just add a post-build command to your project to automatically remove the readonly flag when you run your project.   To do this right-click on your project in the Solution Explorer and select properties.  Go to the Build Events tab and enter the command : attrib -r “$(ProjectDir)Web.Config” .

attrib -r "$(ProjectDir)Web.Config"

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.