c# - Properly set a list of COM objects to a new value -


suppose have list of com objects property in class :

public list<legacycomobjects> legacycomobjects { get; set; } 

what best way set property new value? should classic .net way or should release objects before setting because memory leaks may happen? think of :

private list<legacycomobjects> _legacycomobjects ;  public list<legacycomobjects> legacycomobjects      {         { return _legacycomobjects; }         set              {                  if (_legacycomobjects!= null)                 {                     _legacycomobjects.foreach(o =>                     {                         marshal.releasecomobject(o);                         o = null;                     });                 }                 _legacycomobjects= value;              }     } 


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -