@@ -42,7 +42,7 @@ internal abstract partial class ActiveScriptJsEngineBase : InnerJsEngineBase
4242 /// <summary>
4343 /// List of host items
4444 /// </summary>
45- protected readonly Dictionary < string , object > _hostItems = new Dictionary < string , object > ( ) ;
45+ protected Dictionary < string , object > _hostItems = new Dictionary < string , object > ( ) ;
4646
4747 /// <summary>
4848 /// Last Active Script exception
@@ -77,14 +77,12 @@ internal abstract partial class ActiveScriptJsEngineBase : InnerJsEngineBase
7777 /// <summary>
7878 /// List of document names
7979 /// </summary>
80- private readonly Dictionary < UIntPtr , string > _documentNames =
81- new Dictionary < UIntPtr , string > ( ) ;
80+ private Dictionary < UIntPtr , string > _documentNames = new Dictionary < UIntPtr , string > ( ) ;
8281
8382 /// <summary>
8483 /// List of debug documents
8584 /// </summary>
86- private readonly Dictionary < UIntPtr , DebugDocument > _debugDocuments =
87- new Dictionary < UIntPtr , DebugDocument > ( ) ;
85+ private Dictionary < UIntPtr , DebugDocument > _debugDocuments = new Dictionary < UIntPtr , DebugDocument > ( ) ;
8886
8987 /// <summary>
9088 /// Next source context
@@ -174,14 +172,6 @@ protected ActiveScriptJsEngineBase(JsEngineSettings settings, string clsid,
174172 }
175173 }
176174
177- /// <summary>
178- /// Destructs an instance of the Active Script engine
179- /// </summary>
180- ~ ActiveScriptJsEngineBase ( )
181- {
182- Dispose ( false ) ;
183- }
184-
185175
186176 /// <summary>
187177 /// Checks a support of the JS engine on the machine
@@ -910,25 +900,45 @@ public override void CollectGarbage()
910900 /// Destroys object
911901 /// </summary>
912902 public override void Dispose ( )
913- {
914- Dispose ( true /* disposing */ ) ;
915- GC . SuppressFinalize ( this ) ;
916- }
917-
918- /// <summary>
919- /// Destroys object
920- /// </summary>
921- /// <param name="disposing">Flag, allowing destruction of
922- /// managed objects contained in fields of class</param>
923- private void Dispose ( bool disposing )
924903 {
925904 if ( _disposedFlag . Set ( ) )
926905 {
906+ if ( _debuggingStarted && _debugDocuments != null )
907+ {
908+ foreach ( UIntPtr debugDocumentKey in _debugDocuments . Keys )
909+ {
910+ var debugDocumentValue = _debugDocuments [ debugDocumentKey ] ;
911+ debugDocumentValue . Close ( ) ;
912+ }
913+
914+ _debugDocuments . Clear ( ) ;
915+ _debugDocuments = null ;
916+ }
917+
918+ if ( _processDebugManagerWrapper != null )
919+ {
920+ _processDebugManagerWrapper . RemoveApplication ( _debugApplicationCookie ) ;
921+
922+ if ( _debugApplicationWrapper != null )
923+ {
924+ _debugApplicationWrapper . Close ( ) ;
925+ _debugApplicationWrapper = null ;
926+ }
927+
928+ _processDebugManagerWrapper = null ;
929+ }
930+
931+ if ( _documentNames != null )
932+ {
933+ _documentNames . Clear ( ) ;
934+ _documentNames = null ;
935+ }
936+
927937 _dispatcher . Invoke ( ( ) =>
928938 {
929939 if ( _dispatch != null )
930940 {
931- ComHelpers . ReleaseComObject ( ref _dispatch , ! disposing ) ;
941+ Marshal . ReleaseComObject ( _dispatch ) ;
932942 _dispatch = null ;
933943 }
934944
@@ -939,30 +949,13 @@ private void Dispose(bool disposing)
939949 }
940950 } ) ;
941951
942- if ( disposing )
952+ if ( _hostItems != null )
943953 {
944- if ( _debuggingStarted && _debugDocuments != null )
945- {
946- foreach ( UIntPtr debugDocumentKey in _debugDocuments . Keys )
947- {
948- var debugDocumentValue = _debugDocuments [ debugDocumentKey ] ;
949- debugDocumentValue . Close ( ) ;
950- }
951-
952- _debugDocuments . Clear ( ) ;
953- }
954-
955- if ( _processDebugManagerWrapper != null )
956- {
957- _processDebugManagerWrapper . RemoveApplication ( _debugApplicationCookie ) ;
958- _debugApplicationWrapper . Close ( ) ;
959- }
960-
961- _documentNames ? . Clear ( ) ;
962- _hostItems ? . Clear ( ) ;
963-
964- _lastException = null ;
954+ _hostItems . Clear ( ) ;
955+ _hostItems = null ;
965956 }
957+
958+ _lastException = null ;
966959 }
967960 }
968961
0 commit comments