Groups | Blog | Home
all groups > visual c > august 2003 >

visual c : Sink managed (DataTable) event from unmanaged class?


Bob Whiton
8/28/2003 10:03:41 AM
I have an unmanaged class which has a member variable:
gcroot<DataTable*> myDataTable;

I would like to sink the RowDeleting event in my UNmanaged class. However,
I can't declare an event handler in the unmanaged class because the types
are managed (compiler error C3265).

For example, I can't declare the following sink:
static void Row_Deleting(Object* sender,
System::Data::DataRowChangeEventArgs* e)

Any ideas?

Brandon Bray [MSFT]
8/31/2003 6:12:58 PM
[quoted text, click to view]

Hi Bob,
Declaring a function that uses managed types within a native class is
okay. The C3265 error should be referring to something else, like putting a
managed data member in a native class.

Unfortunately, this still does not solve your problem. In order for a
delegate to bind to a function, the function needs to be a member of a
managed class. Thus, the only way for you to create a sink for an event is
to create another managed class that the native class can access.

This is something that we're spending a lot of time thinking about.
Hopefully, the next version of Visual C++ will provide a better means for
accomplishing what you're doing. I'm sorry that it isn't that easy right
now.

Cheerio!

--
Brandon Bray Visual C++ Compiler
This posting is provided AS IS with no warranties, and confers no rights.

AddThis Social Bookmark Button