I have a class whose definition is as follows.
class SampleClass: public IDispatchImpl<Interface1, &__uuidof(Interface1)>,
public IDispatchImpl<Interface2, &__uuidof(Interface2)>,
public IDispatchImpl<Interface3, &__uuidof(Interface3)>,
public CComObjectRootEx<CComSingleThreadModel>
{
BEGIN_COM_MAP(SampleClass)
COM_INTERFACE_ENTRY(Interface1)
COM_INTERFACE_ENTRY(Interface2)
COM_INTERFACE_ENTRY(Interface3)
COM_INTERFACE_ENTRY2(IDispatch, Interface1)
END_COM_MAP()
..............................
..............................
}
And this is how I'm instantiating my class.
CComObject<SampleClass> *t;
CComObject<SampleClass>::CreateInstance(&t);
The above code is throwing a null pointer exception @ the line shown below.(From "atlcom.h" file).
template <class Base>
class CComObject :
public Base
{
public:
typedef Base _BaseClass;
CComObject(_In_opt_ void* = NULL) throw()
{
_pAtlModule->Lock(); //_pAtlModule is NULL,and hence NULL pointer exception is thrown
}
..............................
..............................
}
I think there is some problem with the definition of the SampleClass. Can anyone help me to figure it out? Thanks in advance..