diff --git a/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs b/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs index 7bb9c6f15..9597d7fa4 100644 --- a/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs +++ b/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs @@ -267,6 +267,7 @@ public void Write () public void Dispose () { + writer.Close (); } } diff --git a/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs b/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs index f309f2f6c..68bbfa90d 100644 --- a/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs +++ b/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs @@ -30,6 +30,7 @@ static extern int CoCreateInstance ( readonly ISymUnmanagedWriter2 writer; readonly Collection documents; + bool closed = false; public SymWriter () { @@ -78,11 +79,14 @@ public void DefineConstant2 (string name, object value, int sigToken) public void Close () { - writer.Close (); - Marshal.ReleaseComObject (writer); + if( !closed ) { + closed = true; + writer.Close (); + Marshal.ReleaseComObject ( writer ); - foreach (var document in documents) - Marshal.ReleaseComObject (document); + foreach( var document in documents ) + Marshal.ReleaseComObject ( document ); + } } public void CloseMethod ()