Asynchronous WCF Calls - Always Check Your State

Published on

Photo by Icons8 Team on Unsplash

After beating my head against the wall for a few days, I feel like I should share my experience with the world. Maybe you won't have the headache I've had.

I have a WCF service reference. I wanted to make a call asynchronously, wcfClient.ProcessTransaction(arguments, null) /* no call back method */. The synchronous call worked just fine, but the asynchronous call failed silently. After much wailing and gnashing of teeth, I discovered that the channel state on the wcfClient never made it past Opening. The solution was just to manually call wcfClient.Open()  before making the asynchronous call.

Hopefully this will help someone avoid my three day headache.