Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 215379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:27:53+00:00 2026-05-11T18:27:53+00:00

I have successfully upgraded an MFC application which was compiled with an old version

  • 0

I have successfully upgraded an MFC application which was compiled with an old version of Developer Studio to Visual Studio 2008. A very small number of changes were needed because of some breaking changes in MFC. Now that everything works, I’d like to take the next step and compile the solution with /clr.

To do so, I have found useful information on the MSDN web site:

  • How to: Migrate to /clr
  • How to: Compile MFC and ATL Code with /clr

Here are the steps I have taken:

  1. Set the Runtime Library to Multi-threaded Debug DLL (/MDd).
  2. Set the Use of MFC to Use MFC in a Shared DLL.

However, doing so prevents me from linking the project:

  1. The reference to afxData can no longer be resolved; somehow, afxData is only visible when linking statically against MFC. In my code, I have the following declaration:

    extern AFX_DATA AUX_DATA afxData;

    which works fine with the statically linked MFC version.

  2. The references to _afxThreadState and _afxWinState cannot be resolved either.

Here are the full error messages :

error LNK2001: unresolved external symbol "struct AUX_DATA afxData" (?afxData@@3UAUX_DATA@@A)
error LNK2001: unresolved external symbol "class CThreadLocal<class _AFX_THREAD_STATE> _afxThreadState" (?_afxThreadState@@3V?$CThreadLocal@V_AFX_THREAD_STATE@@@@A)
error LNK2001: unresolved external symbol "class CProcessLocal<class _AFX_WIN_STATE> _afxWinState" (?_afxWinState@@3V?$CProcessLocal@V_AFX_WIN_STATE@@@@A)

in case this might be related to the name mangling…

So, what can I do in order to dynamically link against MFC, but still reference afxData, _afxThreadState and _afxWinState?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:27:54+00:00Added an answer on May 11, 2026 at 6:27 pm

    When using MFC in a shared DLL, AUX_DATA must be dllimported.

    extern __declspec(dllimport) AUX_DATA afxData
    

    For thread state, rather than using template classes, use one of these

    AFX_MODULE_THREAD_STATE* pState = _AFX_CMDTARGET_GETSTATE()->m_thread;
    AFX_THREAD_STATE* pState = AfxGetThreadState(); 
    

    Depending on the state information you require. For example, see here for some members that were moved to module state to fix a bug. Note that AfxGetModuleThreadState exists but is undocumented and could be changed in a future version.

    Win state does not ring a bell, how is it used? There is probably a new way to accomplish it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 274k
  • Answers 274k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The issue is probably due to the default easing method… May 13, 2026 at 2:26 pm
  • Editorial Team
    Editorial Team added an answer It's a hard call - the <a name="D"></a> doesn't add… May 13, 2026 at 2:26 pm
  • Editorial Team
    Editorial Team added an answer instead of assigning the value to the zone area, create… May 13, 2026 at 2:26 pm

Related Questions

I've been asked to extend a simple legacy application by adding a few tables
Would any experienced Erlang programmers out there ever recommend association lists over records? One
I have an Java applet that loads native code through JNI. Everything worked just
First of all, I'm working in SQL Server 2000 (although prayers have been made

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.