473,473 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Bug: handling __value class events from another assembly

If a __value class with an event is put into an assembly, and a __gc class
in another assembly attempts to attach its own event handler to the __value
class's event of an embedded object of the __value class type, everything
compiles correctly but the Linker puts out error "LINK : error LNK2020:
unresolved token (0A000003) AValueClassEvent" followed by "LINK : fatal
error LNK1120: 1 unresolved externals". If the __value class is in the same
assembly as the __gc class, everything is fine and there is no linker error.
What follows is code illustrating this bug.

In one assembly:

// ValueClass.h
#pragma once
namespace ValueClass
{
public __value class AValueClass
{
public:
AValueClass();
__event System::EventHandler * AValueClassEvent;
int AnInt;
};
}

// ValueClass.cpp
#include "stdafx.h"
#include "ValueClass.h"
ValueClass::AValueClass::AValueClass() : AnInt(1) {}

In a second assembly which references the first assembly:

// HandleValueClassEvent.h
#pragma once
namespace HandleValueClassEvent
{
public __value class AnotherValueClass
{
public:
AnotherValueClass();
__event System::EventHandler * AnotherValueClassEvent;
int AnotherInt;
};
public __gc class HandleEvent
{
public:
HandleEvent();
void AMemberFunction();
void AnotherMemberFunction();
private:
ValueClass::AValueClass avc;
HandleValueClassEvent::AnotherValueClass anvc;
void AnEventHandler(System::Object *,System::EventArgs *);
};
}

// HandleValueClassEvent.cpp
#include "stdafx.h"
#include "HandleValueClassEvent.h"
HandleValueClassEvent::HandleEvent::HandleEvent() {}
void HandleValueClassEvent::HandleEvent::AMemberFunctio n()
{
avc.AValueClassEvent += new System::EventHandler(this,AnEventHandler);
}
void HandleValueClassEvent::HandleEvent::AnotherMemberF unction()
{
anvc.AnotherValueClassEvent += new
System::EventHandler(this,AnEventHandler);
}
void HandleValueClassEvent::HandleEvent::AnEventHandler (System::Object *
sender,System::EventArgs * e) {}
HandleValueClassEvent::AnotherValueClass::AnotherV alueClass() :
AnotherInt(1) {}

The attempt to add an event handler to avc.AValueClassEvent, which is in
another assembly, causes the linker error. If you comment it out there is no
error. The attempt to add an event handler to anvc.AnotherValueClassEvent,
which is the same assembly, causes no error.

Since I have designed a number of __value classes in their own assembly
which have events which must be caught by __gc classes in other assemblies,
I badly need a workaround to this problem else I have to scrapped my own
logical design, or make the __value classes into __gc classes instead.
Nov 17 '05 #1
0 1176

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

Similar topics

16
by: Edward Diener | last post by:
Is there a way to override the default processing of the assignment operator for one's own __value types ? I realize I can program my own Assign method, and provide that for end-users of my class,...
5
by: Edward Diener | last post by:
This has occurred in MC++, but since there is very little response on that NG, I am also reporting it here in the hope that someone can find me a workaround, and report it to MS. If a __value...
2
by: Eric Newton | last post by:
VB's more declarative nature of handling events is golden. I'm hoping C# will acquire this type of deal, in addition to the anonymous delegates. could do same as vb (actually would be easier to...
8
by: Edward Diener | last post by:
I have a __value class which uses some legacy C++ code. So I wrapped the legacy C++ code in another __nogc class and have a pointer to that class as a member of my __value class. When the __value...
15
by: Edward Diener | last post by:
Why is it impossible to have a __value class instance variable in a __nogc class when it is possible to have a built-in type instance variable in a __nogc class ? __value class X { int a; };...
1
by: Yuan Ze | last post by:
The compiler can not compile the code boxing/unboxing value types declared in a MG C++ class. It reports compiler error 2248, 'member' : cannot access member declared in class 'class'. To use a...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.