Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Error C3741
Collapse the table of content
Expand the table of content

Compiler Error C3741

'class': must be a coclass when the 'layout_dependent' parameter of event_receiver = true

When layout_dependent=truefor an event_receiver class, then the class must also have the coclass attribute.

The following sample generates C3741

// C3741.cpp
// compile with: /c
// C3741 expected
#include <atlbase.h>
#include <atlcom.h>

[object, uuid("00000000-0000-0000-0000-000000000001")]
__interface I{ HRESULT f(); };

// Delete the following line to resolve.
[ event_receiver(com, layout_dependent=true)]

// class or struct must be declared with coclass
// Uncomment the following line to resolve.
// [ event_receiver(com, layout_dependent=true), coclass, uuid("00000000-0000-0000-0000-000000000002")]
struct R : I {
   HRESULT f(){ return 0; }
   R(I* a){ __hook(I, a); }

Community Additions

© 2015 Microsoft