Am working on a .Net windows application which internally uses a COM dll. Out of the following 4 ways of releasing a COM object, which is the best one?
1.
if (obj != null)
{
Marshal.ReleaseComObject(obj);
}
2.
if (obj != null)
{
Marshal.ReleaseComObject(obj);
obj=null;
}
3.if (obj != null)
{
Marshal.FinalReleaseComObject(obj);
}
4.if (obj != null)
{
Marshal.FinalReleaseComObject(obj);
obj=null;
}
Thanks for reading.