473,781 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bug in VC++ 2003: Linker unresolved token when accessing __event between assemblies

Scenario:
base class in one assembly, derived class in another assembly, __event in
base class, testing if event has any handlers in derived class with 'if
(OnTestEvent) { //etc. }'.

Result:
LINK : error LNK2020: unresolved token (0A000004) OnTestEvent
LINK : fatal error LNK1120: 1 unresolved externals

Reproduce:
Create a Blank solution, create two projects, both VC++ Class Library .NET,
call one BaseClass, the other DerivedClass. Create dependency of
DerivedClass project on BaseClass project. Add reference of BaseClass to
DerivedClass.

Files:
--------------
BaseClass.h
--------------
#pragma once
namespace BaseClass
{
public __gc class ABaseClass
{
public:
ABaseClass();
__event System::EventHa ndler * OnTestEvent;
private:
int anInt;
};
}
--------------
BaseClass.cpp
-----------------
#include "stdafx.h"
#include "BaseClass. h"
BaseClass::ABas eClass::ABaseCl ass() : anInt(0)
{
}
------------------
DerivedClass.h
------------------
#pragma once
namespace DerivedClass
{
public __gc class ADerivedClass : public BaseClass::ABas eClass
{
public:
ADerivedClass() ;
void TestEventAccess ();
private:
char ch;
};
}
---------------------
DerivedClass.cp p
---------------------
#include "stdafx.h"
#include "DerivedClass.h "
DerivedClass::A DerivedClass::A DerivedClass() : ch(0)
{
}
void DerivedClass::A DerivedClass::T estEventAccess( )
{
if (OnTestEvent)
{
System::EventAr gs * evargs(new System::EventAr gs);
OnTestEvent(thi s,evargs);
}
}

Comments:
If one leaves out the "if (OnTestEvent)" in the derived class and just
triggers the event, no linker errors occur. However I find it a natural
idiom to test if there are any event handlers so as not to execute code,
which may depend on event handlers existing and being called for an event,
if no event handler exists. Is there any other viable workaround for this
bug other than not to do the test for event handlers existing before
triggering the event ?
Nov 17 '05 #1
0 1060

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

Similar topics

0
1243
by: Robert A Riedel | last post by:
In a module DATA.CPP, when attempting to initialize a __gc array as follows: // // Begin sample ... // // // Yes, I include all of the correct assemblies, including MSCORLIB.DLL and all of // the other .NET related paraphernalia.
3
7368
by: Leith Bade | last post by:
I have been trying to use the new Visual C++ Toolkit 2003 with the VC6 IDE I set up the executable, inlcude, and library directories to point to the new compilers I had to fix a few errors in the MFC6 <afxtempl.h> to get it to compile with the better standards confomance (mainly omitted typename, and lazyness with specialized templates - using BASE_CLASS & TYPE instead of CObList & CObList*) Now I get some strange linker errors, and I don't...
4
1460
by: Dan Diephouse | last post by:
I am attempting to write a DLL which wraps C# code. The issue at hand is a print driver allows you to extend it by writing a DLL. Seeing that VC++ seems to be hopelessly out of my mental reach, I thought I'd write the DLL in C#. Of course, it turns out I can't solely write the DLL in C# managed code. I have to create an unmanaged wrapper. So I have the following stub below which I need to fill in. I've gotten to the point where it...
3
1607
by: SHC | last post by:
Hi all, 1) I have used VC++.NET 2002 (v7.0) for a while. Recently I just installed VC++.NET 2003 (v7.1) - I saw the message "Settings were not migrated from Visual Studio.NET 2002 to Visual Studio,NET 2003" during the installation. Do I have to do the migration of the "Settings" if I want to use the both versions of VC++.NET in the Side-by-Side fashion? 2) I ran the "Build" of the example 'Chapter5_Example1' of 'Beginning DirectX 9' by...
3
8087
by: Chucker | last post by:
Hi Folks, I got a Wrapper Dll around a native C++ static library. In .NET 1.1 this worked fine. When moving to .NET 2.0 I get a couple of unresolved externals / linker errors: Error 16 error LNK2028: unresolved token (0A000007) "extern "C" void __clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)" (?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in function "public: virtual __thiscall...
1
935
by: clintmiller | last post by:
here's the header: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #pragma once using namespace System; #define MapCascadeError(CasErrorEnum) \ static GeometryException* MapError(CasErrorEnum error, String* message, Exception* innerException); \
8
2322
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR types. The problem: I have a number of mixed-mode functions which I want reuse. These functions revolve around converting a CLR String to a C++ std::string or
4
6412
by: Sanjay Kumar | last post by:
Folks ! I am working with VC++ after a long time and having problem linking latest xerces 2.7 in VC++ 2005 Express Edition. I have done following: 1. downloaded and unpacked the the library: http://www.apache.org/dist/xml/xerces-c/binaries/xerces-c_2_7_0-windows_2000-msvc_60.zip
1
4163
by: Deepath G | last post by:
This is deepath.. I am getting some linker error when i am trying to connect Websphere MQ using Borland C++ Builder 2006 using imqi.hpp on windows. Error Message ----------------------- Error: Unresolved external 'ImqMgr::~ImqMgr()' referenced from C:\DOCUMENTS AND SETTINGS\228753\MY DOCUMENTS\BORLAND STUDIO PROJECTS\DLLEXERCISE\DEBUG_BUILD\MANI.OBJ Error: Unresolved external 'ImqObj::~ImqObj()' referenced from C:\DOCUMENTS AND...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10139
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6727
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.