This question is about using Visual Studio 2019 for building an out-of-process COM server using ATL. (I have done this before in Borland but this is my first time using MSVC).
I created a project called MyObjectsProject
with ATL Project wizard. This created the module class CMyObjectsProjectModule : public ATL::CAtlExeModuleT<CMyObjectsProjectModule>
in file MyObjectsProject.cpp
.
Then I added a simple object MyObject
via "Add > ATL Simple Object" as described in the documentation . This created files MyObject.cpp
and MyObject.h
containing an interface IMyObject
and CoClass CMyObject
. So far so good.
I go to IMyObject
in the Class View, and right-click "Add > Method" and give it some details, then it adds the method declaration to CMyObject
in MyObject.h
and an empty definition to MyObject.cpp
as CMyObject::method_name()
. So far, so good (again).
However at the same time, it added the method declaration and definition to MyObjectsProject.cpp
as a class member of CMyObjectsProjectModule
. Furthermore:
- The
CMyObjectsProjectModule::method_name()
version is never called -- when I use the COM server via a client, and callIMyObject::method_name()
on an instance ofMyObject
, it executes the version defined asCMyObject::method_name()
as expected. - I can delete the method declaration and definition from
CMyObjectsProjectModule
and there are no errors.
The same thing happens if adding a Property. Also, the "Completing operation..." takes about 45-50 seconds to run.
My question is: What is the reason behind the method being added to the Module as well as to the CoClass , and when would that version of the Method be called? (Or is this just a bug and it is not supposed to be added to the module at all?)
In the Borland IDE , the similar function wouldn't add methods to the Module.
EDIT: Originally posted the question with the project called MyProject
, however the problem only occurs when the project is called MyObjectsProject
. I used different names in the question originally from what I observed the problem with, but have now edited the question and reproduced using the exact names in the question.