Setting Objects to Null/Nothing after use in .NET

Should you set all the objects to null (Nothing in VB.NET) once you have finished with them? I understand that in .NET it is essential to dispose of any instances of objects that implement the IDisposable interface to release some resources although the object can still be something after it is disposed (hence the isDisposed … Read more

WPF User Control Parent

I have a user control that I load into a MainWindow at runtime. I cannot get a handle on the containing window from the UserControl. I have tried this.Parent, but it’s always null. Does anyone know how to get a handle to the containing window from a user control in WPF? Here is how the … Read more

C# Ignore certificate errors?

I am getting the following error during a web service request to a remote web service: Could not establish trust relationship for the SSL/TLS secure channel. —> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure. Is there anyway to ignore this error, and continue? It seems the remote certificate is not signed. … Read more

What is ApplicationException for in .NET?

To throw exceptions, I usually use built-in exception classes, e.g. ArgumentNullException and NotSupportedException. However, sometimes I need to use a custom exception and in that case I write: class SlippedOnABananaException : Exception { } class ChokedOnAnAppleException : Exception { } and so on. Then I throw and catch these in my code. But today I … Read more

Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug

Update: A sample project reproducing this bug can be found here at Microsoft Connect. I have also tested and verified that the solution given in the accepted answer below works on that sample project. If this solution doesn’t work for you, you are probably having a different issue (which belongs in a separate question). This … Read more