File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Rubberduck.VBEEditor/SafeComWrappers Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1
- using System . Runtime . InteropServices ;
1
+ using System ;
2
+ using System . Runtime . InteropServices ;
2
3
using System . Runtime . InteropServices . ComTypes ;
3
4
using Rubberduck . VBEditor . SafeComWrappers . Abstract ;
4
5
@@ -44,8 +45,14 @@ public void AttachEvents()
44
45
var g = typeof ( TEventInterface ) . GUID ;
45
46
icpc . FindConnectionPoint ( ref g , out _icp ) ;
46
47
47
- // Pass a pointer to the host to the connection point
48
- _icp . Advise ( this as TEventInterface , out _cookie ) ;
48
+ var sink = this as TEventInterface ;
49
+
50
+ if ( sink == null )
51
+ {
52
+ throw new InvalidOperationException ( $ "The class { this . GetType ( ) } does not implement the required event interface { typeof ( TEventInterface ) } ") ;
53
+ }
54
+
55
+ _icp . Advise ( sink , out _cookie ) ;
49
56
}
50
57
}
51
58
You can’t perform that action at this time.
0 commit comments