this case is bothering me since morning. Is it good practice to call garbage collector in class constructor if it throws Exception ? I have something like this:
public MyClass(/* some arguments */)
{
try
{
//do stuff...
} catch(Exception e) {
//do stuff, save logfile
GC.SuppressFinalize(this);
}
}
The reason that I did it like this is that if it threw Exception (usualy NullreferenceException) I want to log it in text file and I don't need/want this object anymore. but is it good practice? If not how to do it properly?
GC.SuppressFinalizeis completely pointless.