Click here to Skip to main content
13,086,019 members (82,658 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I came across an odd feature in Visual Studio 2012 today.

The symptom is that an executable was unable to find an exported function in one our DLLs. This code functions properly when built in VS 2008.

I finally determined the issue. The calling executable was looking for a virtual destructor for the class, but the class itself did not contain a virtual destructor. There is a mismatch in the name mangling between the dll and the caller.

Clearly the workaround is simple and straight forward. But it will take time to find all of the instances in our code where this manifests.

Is this a new requirement of 2012, or a bug?
Posted 10-Jul-13 10:27am
Sergey Alexandrovich Kryukov 10-Jul-13 16:28pm
A code sample could help to understand the issue...
JackDingler 10-Jul-13 16:47pm
I may try a code sample this evening. Should be easy to reproduce.

I'm in the habit of making destructors virtual by default.
In this case I'm porting legacy code.
The_Inventor 11-Jul-13 2:32am
MSW has been closing the security holes where it can find them. There was a big change in VS2012 from VS2008. VS is no exception. Not having a destructor, virtual or otherwise, in a .dll is bad if there is a class structure involved. It leaves fragments of memory open to abuse.
JackDingler 11-Jul-13 9:17am
No there is a destructor.

The class definition says it's non-virtual. The exported function in the DLL is clearly marked as non-virtual.

But the calling application is looking for a virtual destructor and not finding it.

What surprised me is that it didn't produce a link time error. I'll check the lib file and see if it differs from the DLL.
JackDingler 11-Jul-13 10:36am
I think I solved the mystery, what likely happened is that I had changed the class to a virtual, and then reverted the change, but the project make didn't update the library on the revert.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Microsoft requires it. Read it for yourself: a little funny: "Note that these rules are the same for nonexportable classes."[^]
JackDingler 15-Jul-13 14:00pm
Thank you very much. My 5. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 15 Jul 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100