Partilhar via


Server Collection Cannot Be Empty Error When Using Azure AppFabric Caching in Winforms Application

I had a problem that unfortunately I've seen a few people run across when using the AppFabric caching feature of Windows Azure.  This is the release version of the caching mechanism formerly known as Velocity.  When you have a problem with the caching factory that it uses, most frequently the error message you will see thrown is along the lines of "server collection cannot be empty".  Unfortunately that is another ubiquitous error that is frequently fairly difficult to track down.  In this case it was even more perplexing - I had a compiled standalone assembly that was making use of the cache.  When I called that assembly from an Azure worker role I wasn't getting any errors at all.  However, when I added a reference to the assembly to my winforms test application and tried running it, I got the dreaded error.

After a fair amount of poking around, de-hairing my head one strand at a time, and soul searching (why am I here, why do I work on this stuff), it finally hit me what the problem was.  Even though my winform app was not directly invoking the caching classes, it was the host process.  All that means is that all of the cache configuration entries that were in my worker role application, had to be added to the app.config of my winforms application.  Once I added them in everything worked fine.

This type of scenario is somewhat common I suppose, but since this error is such a pain to track down I thought I would capture here for folks caught in a similar predicament.

Comments