hi,
i had this error but got a simple fix
you don't need all that code, all you need is to do is in the beginning of your application download the cookie like this (sorry but i work with VB :) but is pretty simple to convert)
[your application namespace].Application.GetCookie(New Uri("https://[site]"))
Greetings from Portugal
Gandum