Click here to Skip to main content
13,252,815 members (50,808 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked
Posted 19 Apr 2013

COM Executable Crash compiled with VS2012 on Windows 2012

, 19 Apr 2013
Rate this:
Please Sign up or sign in to vote.
If you are migrating your COM application to Visual Studio 2012 then this could be helpful for you.

I faced this problem while migrating one of my COM applications from VS2008 to VS2012.

Problem: COM application crashes when compiled with VS2012 on Windows 2012

  1. Search for a class like below in your code which inherits from CAfwAtlExeModuleT<>.
  2. class CAsset_Tree_Module : public CAfwAtlExeModuleT< CAsset_Tree_Module >
    </li />
  3. You might see a method similar to the one below in that class (if yes than there is a trap):
  4. HRESULT RegisterClassObjects(DWORD dwClsContext, DWORD dwFlags) throw()
        return AtlComModuleRegisterClassObjects(&_AtlComModule, CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE);
  5. As per Microsoft, in Visual Studio 2012, this function cannot be used in applications that execute in the Windows Runtime.

Just change the version of Visual Studio (2010 to 2012) in the above link to see the difference. 

Here is the solution:

Replace this line:

return AtlComModuleRegisterClassObjects(&_AtlComModule, CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE);

with this code block:

#if _MSC_VER > 1600
    dwFlags |= REGCLS_SINGLEUSE;
    return __super::RegisterClassObjects(dwClsContext,dwFlags);

    return AtlComModuleRegisterClassObjects(&_AtlComModule, 


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


About the Author

Chandra Shekhar Joshi
Software Developer (Senior) ABB
India India
Working in Software Development since 2007.
Work in .Net/VC++/COM.
work in Process Automation domain.

You may also be interested in...

Comments and Discussions

QuestionMigrated application Crashing Pin
Rajkumar Selvaraj11-Nov-14 6:46
memberRajkumar Selvaraj11-Nov-14 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 19 Apr 2013
Article Copyright 2013 by Chandra Shekhar Joshi
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid