473,325 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Serious bug discovered in VC .NET (2002) compiler. [event_source(native)] and __event methods

Serious bug discovered in VC .NET (2002) compiler.

Example below should work if I understand the Microsoft documentation
correctly.

Hopfelly there is some compiler upgrade that fixes this bug?
[event_source(native)]
class CTubeDev {
....
__event void OnEnableControls(const BOOL abEnable);
....
};
[event_receiver(native)]
class CPowerDlg : public CDialog {
....
void DoEnableControls(const BOOL abEnable);
....
}

Somewhere in CPowerDlg I call the hook function only once:

__hook(&CTubeDev::OnEnableControls,m_pDev, &CPowerDlg::DoEnableControls);

I take care that the __hook is only called once and no __unhook is called
before a __hook.

So when I call OnEnableControls() from a CTubeDev instance, then the
DoEnableControls() is correctly called, processed but when returning back to
the CTubeDev instance I get an access violation.

Reverse engeneering suggests that there is a node->next pointer that is not
initialized to NULL in the events list handler when the class is created.

A very dirty fix so far to make this system work as it should, is to try to
find the hidden generated attribute created by the __event keyword, and
initialize this to NULL in the constructor, like this.

//--------------------------------------------------------------------

CTubeDev::CTubeDev()
{
__eventHandlerList_CTubeDev_OnEnableControls=NULL;
.....
}

Reverse engineering suggests that the hidden attribute names generated by
__event is of format:

__eventHandlerList_<ClassName>_<EventMethod>

Nov 16 '05 #1
1 1264
I want to add that I do not use managed code, and I link with the multi
threaded static libraries.
And this too might help:
Compiler directives :

/GA /I "..\..\base" /D "_MBCS" /FD /EHsc /RTC1 /MTd /Zp16 /GS /Gy
/Fp".\Debug/TubeDev.pch" /Fo".\Debug/" /Fd".\Debug/" /FR".\Debug/" /W3
/nologo /c /Wp64 /Zi /TP
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and...
2
by: Michael Kennedy [UB] | last post by:
public __gc class CWADataManagerEvents { public: __event void CreateGauge(String * type, bool shared, String * name, GaugeCreateSettings * settings); __event void SetupGauge(unsigned short GID,...
5
by: Joe Thompson | last post by:
Hi, I am using VC++.Net 2003 with WinForms to write a serial port application. I downloaded the newest VC++ examples from MSDN and found a project called Using the COM Port. In it, there is a...
1
by: | last post by:
I want to hook events handlers but need to test of any event handler is assigned or not. I need something like this: __event void OnEventHandler(Myfunc) .... if (OnEventHandler)...
2
by: Boris Fortes | last post by:
I need to unhook event receiver as result of native C++ event. It unhooks successfully, but __raise does not return and throws access violation. Visual Studio 2003 How to reproduce: Consol...
0
by: Lord2702 | last post by:
Sun. Aug. 29, 2004 5:00 PM PT I have a user control class which defined as follows... public __gc class MyControl : public UserControl { //---- //-- other fields methods and properties....
0
by: Dave L | last post by:
I just upgraded from VS .NET 2002 to 2003. Everything built okay, but strange bugs started appearing. Apparently there is a bug in the managed C++ compiler in regards to handling of static...
1
by: Edward Diener | last post by:
I have a __gc class, let's call it ClassB, derived from ClassA, which has an __event, and eventually derived from System::ComponentModel::Component. This ClassB has no __event. I derived another...
2
by: Michael Reichenbach | last post by:
http://www.remotesoft.com/linker/intro.html it costs far about $1000. Did someone test it?? Is this serious? Or is there some free or at least more cheap alternative? Why there is no native...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.