Csharp: Small error handling fix