I was frustrated by this error every time i run below code. I did a lot of googleing nothing worked. Even Microsoft said its a know issue we don't recommend this.
Then later just to try I just put one try catch block and it worked perfect. Till date i have not seen that error.