Iam using the OpenConnection开发者_运维问答 from CertAdm.dll to open a connection.
Like this:
CERTADMINLib.CCertView connection = new CERTADMINLib.CCertViewClass();
I was wondering how can I close this connection when Iam done with it? I havent found anything about closing the connection.
Thnx in advance.
It's good practice to use "using" pattern for those kind of connections:
using (CERTADMINLib.CCertView connection = new CERTADMINLib.CCertViewClass())
{
// do something ...
}
after the last brace connections are disposed.
Close the connection so:
ICertView2 certView = null;
IEnumCERTVIEWROW row = null;
try
{
certView = new CCertView();
certView.OpenConnection( _strCAConfig );
certView.SetResultColumnCount( 1 );
certView.SetResultColumn( certView.GetColumnIndex( 0, "RequestID" ) );
row = certView.OpenView();
row.Next();
return row.GetMaxIndex();
}
finally
{
Marshal.ReleaseComObject( row );
Marshal.ReleaseComObject( certView );
}
精彩评论