Sink managed (DataTable) event from unmanaged class?

B

Bob Whiton

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?
 
B

Brandon Bray [MSFT]

Bob said:
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)

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top