@@ -606,6 +606,8 @@ List<RegexResult> GetMatchesFor(string text, string fileName = "", int selection
606606 MatchResultsTreeView . ItemsSource = GetMatchesFor ( sourceScript . Get ( ) . ToString ( ) , "script" ) ;
607607
608608 MatchesResultLabel . Content = $ "{ i } matches [Index,Length] + { countAllCaptures - i } empties matches";
609+
610+ csEval . UnloadOwnerDomain ( ) ;
609611 }
610612 else
611613 {
@@ -737,6 +739,8 @@ private void ReplaceAllButton_Click(object sender, RoutedEventArgs e)
737739 index ++ ;
738740 return script . Replace ( match , index , "script" , index , 0 ) ;
739741 } ) , "script" , null ) ) ;
742+
743+ csEval . UnloadOwnerDomain ( ) ;
740744 break ;
741745 default :
742746 currentFileName = GetCurrentFileName ? . Invoke ( ) ?? string . Empty ;
@@ -749,6 +753,8 @@ private void ReplaceAllButton_Click(object sender, RoutedEventArgs e)
749753 } ) , currentFileName , null ) ) ;
750754 break ;
751755 }
756+
757+ csEval . UnloadOwnerDomain ( ) ;
752758 }
753759 else
754760 {
@@ -809,6 +815,7 @@ private void ReplaceAllButton_Click(object sender, RoutedEventArgs e)
809815 text = script . Get ( ) . ToString ( ) ;
810816 nbrOfElementToReplace = regex . Matches ( text ) . Count ;
811817 SetTextInNew ( regex . Replace ( text , ReplaceEditor . Text ) ) ;
818+ csEval . UnloadOwnerDomain ( ) ;
812819 break ;
813820 default :
814821 text = GetCurrentText ( ) ;
@@ -948,6 +955,10 @@ void Extract(string text, string fileName = "")
948955 {
949956 MessageBox . Show ( ex . Message + ex . StackTrace ) ;
950957 }
958+ finally
959+ {
960+ csEval . UnloadOwnerDomain ( ) ;
961+ }
951962 }
952963
953964 private List < string > GetFiles ( )
@@ -1607,6 +1618,10 @@ private void ReplaceInEditor_MenuItem_Click(object sender, RoutedEventArgs e)
16071618 {
16081619 MessageBox . Show ( exception . Message ) ;
16091620 }
1621+ finally
1622+ {
1623+ csEval . UnloadOwnerDomain ( ) ;
1624+ }
16101625 }
16111626
16121627 private void InsertValueInReplaceField_MenuItem_Click ( object sender , RoutedEventArgs e )
@@ -2120,6 +2135,10 @@ private void TestCSharpTextSourceButton_Click(object sender, RoutedEventArgs e)
21202135 {
21212136 MessageBox . Show ( $ "{ exception } ") ;
21222137 }
2138+ finally
2139+ {
2140+ csEval . UnloadOwnerDomain ( ) ;
2141+ }
21232142 }
21242143
21252144 private void ExportToVisualStudio_Click ( object sender , RoutedEventArgs e )
0 commit comments