Microsoft KB Archive/323307

= FIX: LNK2020 Error Message When a Function Is Called to Retrieve a Delegate to Be Hooked onto an Event =

Article ID: 323307

Article Last Modified on 4/11/2003

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition

-



This article was previously published under Q323307



SYMPTOMS
When you compile code similar to the sample code in the &quot;Steps to Reproduce the Behavior&quot; section, you may receive the following error message:

LINK : error LNK2020: unresolved token (0A000003) DomainUnload

LINK : fatal error LNK1120: 1 unresolved externals



RESOLUTION
To work around the problem, use the following sample code: AppDomain::CurrentDomain->DomainUnload += (unloader->GetHandler);



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Visual C++ .NET (2003).



Steps to Reproduce the Behavior
The linker error occurs only under the following conditions:
 * When you use a function call to retrieve a delegate to be hooked onto an event.

-and-
 * The event uses advanced syntax and is not implemented by using delegates.

To reproduce the problem, run the following code sample: //test.cpp // Compiler Option: cl /clr /LD /FAs test.cpp

using namespace System;
 * 1) using 

__gc private class Unloader { public: void handler(Object *sender,EventArgs *args) { }  Unloader { }  EventHandler *GetHandler {    return new EventHandler(this,handler); } };

__gc public class User { public: User {   Unloader * unloader = new Unloader; AppDomain::CurrentDomain->DomainUnload += unloader->GetHandler; } };

Keywords: kberrmsg kbbug kbfix kbpending kbmanaged KB323307

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.