Click here to Skip to main content
15,901,122 members
Home / Discussions / C#
   

C#

 
GeneralRe: create reg_expand_sz key in registry Pin
Dave Kreskowiak20-Jan-05 13:12
mveDave Kreskowiak20-Jan-05 13:12 
Generalpdf as BackGroundImage Pin
Anonymous19-Jan-05 8:13
Anonymous19-Jan-05 8:13 
GeneralRe: pdf as BackGroundImage Pin
Heath Stewart19-Jan-05 8:33
protectorHeath Stewart19-Jan-05 8:33 
GeneralWindows Service Pin
DotNetAppDeveloper19-Jan-05 7:39
DotNetAppDeveloper19-Jan-05 7:39 
GeneralRe: Windows Service Pin
Heath Stewart19-Jan-05 8:08
protectorHeath Stewart19-Jan-05 8:08 
GeneralRe: Windows Service Pin
DotNetAppDeveloper19-Jan-05 9:17
DotNetAppDeveloper19-Jan-05 9:17 
GeneralCalling COM interface from C# Pin
shayw19-Jan-05 7:36
shayw19-Jan-05 7:36 
GeneralRe: Calling COM interface from C# Pin
Heath Stewart19-Jan-05 7:56
protectorHeath Stewart19-Jan-05 7:56 
What you propose above is a good way of handling such a situation. You simply advise a sink passed to your managed components.

There's several problems, however. When writing CCWs (COM-Callable Wrappers) you need to follow COM best practices. That means attributing your interfaces and coclasses with the GuidAttribute with unique, constant values. Never change an interface definition once published, nor its IID (GuidAttribute value); derive a new interface from it with a different IID and added methods (no overloads, which COM does not support).

So, whether you declare your ISink interface in unmanaged or managed code, make sure you use the same IID.

You might also consider using an interface that is already published for native code: IAdviseSink. This may be more advanced than what you need, however, since it has more to do with clipboard objects (including drag and drop) than anything else.

Also note that while maintaining the same name is a good idea for the interface in both unmanaged and managed code, it's not necessary. So long as the IID and interface definition (including any DispIdAttributes for IDispatch-derived interfaces) are the same, it's the same interface.

You could also declare events for an interface, which creates a dispinterface for the class if you're declaring the sink in managed code to give to unmanaged code. See the ComSourceInterfaceAttribute for more details.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: Calling COM interface from C# Pin
shayw19-Jan-05 8:20
shayw19-Jan-05 8:20 
GeneralRe: Calling COM interface from C# Pin
Heath Stewart19-Jan-05 8:27
protectorHeath Stewart19-Jan-05 8:27 
GeneralRe: Calling COM interface from C# Pin
shayw19-Jan-05 8:48
shayw19-Jan-05 8:48 
GeneralRe: Calling COM interface from C# Pin
Heath Stewart19-Jan-05 8:54
protectorHeath Stewart19-Jan-05 8:54 
GeneralRe: Calling COM interface from C# Pin
shayw20-Jan-05 7:36
shayw20-Jan-05 7:36 
GeneralRe: Calling COM interface from C# Pin
Heath Stewart20-Jan-05 9:35
protectorHeath Stewart20-Jan-05 9:35 
GeneralAccess COM Collection using InvokeMethod Pin
dlgussin19-Jan-05 5:19
dlgussin19-Jan-05 5:19 
GeneralRe: Access COM Collection using InvokeMethod Pin
Heath Stewart19-Jan-05 7:45
protectorHeath Stewart19-Jan-05 7:45 
GeneralRe: Access COM Collection using InvokeMethod Pin
dlgussin19-Jan-05 9:05
dlgussin19-Jan-05 9:05 
GeneralRe: Access COM Collection using InvokeMethod Pin
dlgussin19-Jan-05 15:59
dlgussin19-Jan-05 15:59 
GeneralSMTP Question Pin
WDI19-Jan-05 4:01
WDI19-Jan-05 4:01 
GeneralRe: SMTP Question Pin
Judah Gabriel Himango19-Jan-05 4:42
sponsorJudah Gabriel Himango19-Jan-05 4:42 
GeneralRe: SMTP Question Pin
Heath Stewart19-Jan-05 7:35
protectorHeath Stewart19-Jan-05 7:35 
GeneralExtended Context Menu Pin
realmontanakid19-Jan-05 3:37
realmontanakid19-Jan-05 3:37 
GeneralRe: Extended Context Menu Pin
leppie19-Jan-05 6:08
leppie19-Jan-05 6:08 
GeneralRe: Extended Context Menu Pin
Anonymous19-Jan-05 7:11
Anonymous19-Jan-05 7:11 
GeneralRe: Extended Context Menu Pin
leppie19-Jan-05 8:13
leppie19-Jan-05 8:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.