开发者

C# - ICertView2::OpenConnection Method

开发者 https://www.devze.com 2023-02-28 02:51 出处:网络
Iam using the OpenConnection开发者_运维问答 from CertAdm.dll to open a connection. Like this: CERTADMINLib.CCertView connection = new CERTADMINLib.CCertViewClass();

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 );
}
0

精彩评论

暂无评论...
验证码 换一张
取 消