File tree Expand file tree Collapse file tree 1 file changed +5
-15
lines changed Expand file tree Collapse file tree 1 file changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,12 @@ internal class ComObject : DynamicObject, IDisposable
10
10
{
11
11
private object _instance ;
12
12
#if DEBUG
13
- private readonly Guid _trackingId ;
13
+ private readonly Guid _trackingId = Guid . NewGuid ( ) ;
14
14
#endif
15
15
16
16
public ComObject ( object instance )
17
17
{
18
18
_instance = instance ;
19
- #if DEBUG
20
- _trackingId = Guid . NewGuid ( ) ;
21
- #endif
22
19
}
23
20
24
21
public ComObject ( string progid )
@@ -111,24 +108,17 @@ private static object WrapIfRequired(object obj)
111
108
return obj ;
112
109
}
113
110
114
- private void ReleaseUnmanagedResources ( )
111
+ public void Dispose ( )
115
112
{
113
+ // The RCW is a .NET object and cannot be released from the finalizer anymore,
114
+ // because it might not exist anymore.
116
115
if ( _instance != null )
117
116
{
118
- Marshal . FinalReleaseComObject ( _instance ) ;
117
+ Marshal . ReleaseComObject ( _instance ) ;
119
118
_instance = null ;
120
119
}
121
- }
122
120
123
- public void Dispose ( )
124
- {
125
- ReleaseUnmanagedResources ( ) ;
126
121
GC . SuppressFinalize ( this ) ;
127
122
}
128
-
129
- ~ ComObject ( )
130
- {
131
- ReleaseUnmanagedResources ( ) ;
132
- }
133
123
}
134
124
}
You can’t perform that action at this time.
0 commit comments