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)
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 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: http://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\IISConfigurator126.96.36.199" 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.
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.