MFC Release libraries missing/not exporting _AFXCTL_AMBIENT_CACHE - by elchido

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 750722 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 6/25/2012 7:44:27 AM
Access Restriction Public


I have an old VC 6 project that I'm moving to VS 2012. After some pushing and shoving, I have the Debug configuration compiling, linking, and running fine. However, the Release build fails at link time with this:

error LNK2001: unresolved external symbol "class CThreadLocal<class _AFXCTL_AMBIENT_CACHE> _afxAmbientCache" (?_afxAmbientCache@@3V?$CThreadLocal@V_AFXCTL_AMBIENT_CACHE@@@@A)

I am linking both with the same .libs. What's going on? Is _AFXCTL_AMBIENT_CACHE in a different Release library?

More info: dumpbin shows this for mfc110d.lib:


but it's not there in mfc110.lib
Sign in to post a comment.
Posted by elchido on 6/29/2012 at 1:47 PM
Pat, this is part of the runtime of ASNA Visual RPG (written since the days of C++ 4.2, most recently in VC 6). This class is used in 2 of the controls it supports, plus in the base classes that implement the support for user creation of activeX controls. We need to be able to clear the ambient cache under certain circumstances, mainly after loading the state of a user control or after a call to InitNew in the implementation of IPersistPropertyBag, as calls to COleControl::GetAmbientProperty may get stale values. If there's any other way to achieve this I'm all ears.
Posted by Microsoft on 6/29/2012 at 10:56 AM

The AFXCTL_AMBIENT_CACHE export is filtered out (only for the Release DLL) during our MFC export generation process. It has been this way since at least 2000, long before I started maintaining MFC. My best guess is that there is a good reason for the filtering. Is the line of code that clears the cache actually a necessary part of your control? Given that you are using private MFC headers I think you are in an unsupported scenario.

Pat Brenner
Visual C++ Libraries Development
Posted by elchido on 6/27/2012 at 3:35 PM
Can someone explain to me why is this being "Closed as External" if this is a VS 2012 MFC bug??? Are you not taking any more MFC bugs?
Posted by elchido on 6/27/2012 at 1:45 PM
Reactivated with VS 2012 recreate of the bug.
Posted by elchido on 6/26/2012 at 12:39 PM
I added more detail to the steps to recreate, and attached a VS 2012 C++ project that shows the behavior.
Posted by elchido on 6/26/2012 at 11:30 AM
Ok, the same thing happens in VS 2012 with the VS 2012 MFC libraries. Dumpbin shows this for mfc110d.lib:

15C __imp_?_afxAmbientCache@@3V?$CThreadLocal@V_AFXCTL_AMBIENT_CACHE@@@@A

but it's not there in mfc110.lib
Posted by Microsoft on 6/26/2012 at 2:17 AM
Thanks for your feedback. But now we are no longer accepting bugs for Microsoft Visual Studio 2010 and earlier products. We only support the latest Visual Studio versions for bug/suggestion. To get help with issues regarding Visual Studio 2010 and earlier, please visit one of the following resources:

Sorry for the inconvenience.

Posted by Microsoft on 6/25/2012 at 7:49 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(