Windows Azure | This communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state

Exception details:

Visual studio throws error "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state. See output window for more information."

Following is the text from my output window:

Windows Azure Tools: Warning: Remapping public port 80 to 81 to avoid conflict during emulation.
Windows Azure Tools: Warning: Remapping private port 80 to 82 in role 'WebRole1' to avoid conflict during emulation.
Windows Azure Tools: 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)
   at System.ServiceModel.Channels.ServiceChannel.System.IDisposable.Dispose()

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at System.IDisposable.Dispose()
   at Microsoft.ServiceHosting.Tools.DevelopmentFabric.FabricClient.AddServiceDeployment(String tenantName, ServiceModelDefinition serviceModelDefinition, String instanceDescriptionPath, ServiceDeploymentOptions options) 

You may encounter a This communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state error when you start your role in the local development environment, which uses the compute emulator.

The error does not occur when deploying the package to Windows Azure in the cloud.

=================================================================================================================================================================================

 

Possible Causes and Resolution:

=================================================================================================================================================================================

Cause 1: The Web.config file is marked read-only in compute emulator.

Resolution: Clear the read-only attribute from the web.config file. If you are using a source control system, you may need to check-out the file.

Cause 2: Multiple role instances are writing to same configuration file in compute emulator.

Resolution: Limit the instance count to one for any given role when using the compute emulator. Before deploying to Windows Azure, reset the instance count to a higher value as desired.

Cause 3: The project has a very large number of files.

Resolution: Limit the number of files included in the project.

Cause 4: Errors in the Web.config file.

Resolution: Correct the errors in the Web.config file.

The above mentioned details are documented in this link: https://msdn.microsoft.com/en-us/library/gg494981.aspx

If none of the above options helped you, check if any of the files present in "%LocalAppData%\dftmp\IISConfigurator1.6.0.0" folder (on your development machine) are marked as "read only".

 

Remove the "read only" property for the files present in the below path (on your development machine). This will fix the issue and enable you to run the application in debug mode.

("%LocalAppData%\dftmp\IISConfigurator1.6.0.0" folder)

Note: IISConfigurator folder name may change based on Windows Azure SDK version you are working on.  

Interestingly, installing Windows Azure connect endpoint on your machine will fix this issue because it resets these file attributes.

=================================================================================================================================================================================

Comments

  • Anonymous
    April 09, 2013
    My solution was to simply change the Application Pool name. There was some setting or state being saved somewhere (I have no idea where) that was linked to the Application Pool name. As soon as I changed the name to something else, using the exact same code, it worked fine. If I change the AppPool name back to the original, it errors again.. Anyone know why this would behave like this? I've tried an iisreset and restarting the server but only changing the AppPool name seems to fix it.. Very odd!

  • Anonymous
    October 14, 2014
    For me, the problem was that the Azure Emulator (v2.4) was not set to Full Mode. Once I changed this, it worked.