Esempio n. 1
0
 /// <summary>
 /// </summary>
 public void Dispose()
 {
     try
     {
         int RefCount;
         if (propNotifyCookie != null)
         {
             propNotifyCookie.Dispose();
             propNotifyCookie = null;
         }
         if (winEvents != null)
         {
             winEvents.Dispose();
             winEvents = null;
         }
         try
         {
             Marshal.ReleaseComObject(window);
         }
         catch
         {
         }
         try
         {
             if (interopDocumentView != null)
             {
                 try
                 {
                     interopDocumentView.Show(0);
                 }
                 catch
                 {
                 }
                 try
                 {
                     interopDocumentView.UIActivate(0);
                 }
                 catch
                 {
                 }
                 try
                 {
                     interopDocumentView.SetInPlaceSite(null);
                 }
                 catch
                 {
                 }
                 long nullParam = 0L;
                 try
                 {
                     interopDocumentView.Close(nullParam);
                     do
                     {
                         RefCount = Marshal.ReleaseComObject(interopDocumentView);
                     } while (RefCount >= 0);
                 }
                 catch
                 {
                 }
                 finally
                 {
                     Marshal.FinalReleaseComObject(interopDocumentView);
                     interopDocumentView = null;
                 }
             }
         }
         catch
         {
         }
         if (oleDocumentObject != null)
         {
             try
             {
                 if (htmlEditor.Site == null || !htmlEditor.Site.DesignMode)
                 {
                     Marshal.FinalReleaseComObject(oleDocumentObject);
                     oleDocumentObject = null;
                 }
             }
             catch
             {
             }
         }
         if (htmlbaseDocument != null)
         {
             do
             {
                 RefCount = Marshal.ReleaseComObject(htmlbaseDocument);
             } while (RefCount >= 0);
             Marshal.FinalReleaseComObject(htmlbaseDocument);
             htmlbaseDocument = null;
         }
         if (interopDocumentView != null)
         {
             do
             {
                 RefCount = Marshal.ReleaseComObject(interopDocumentView);
             } while (RefCount >= 0);
         }
         if (activeObject != null)
         {
             do
             {
                 RefCount = Marshal.ReleaseComObject(activeObject);
             } while (RefCount >= 0);
             Marshal.FinalReleaseComObject(activeObject);
             activeObject = null;
         }
         interopDocumentView = null;
         htmlbaseDocument    = null;
         activeObject        = null;
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }