I am unexpectedly receiving an Error 424 from an object that works.
I have a number of OleAutomation classes written in C++ using ATL.
I can instantiate them with either early or late binding.
I can call methods and properties on them and obtain expected results.
However I receive Error 424 if I test whether they are null.
Are there any suggestions as to the problem ?
Excel VBA code that triggers error:
Sub ObjectTest()
Dim o As About
Set o = New About
' this works - prints 1.4
Debug.Print "Version ", o.Version
' generates Error 424
Debug.Print "About ", o Is Null
End Sub
The IDL
[
object,
oleautomation,
uuid(...),
dual,
nonextensible,
pointer_default(unique),
public
]
interface IAbout : IDispatch
{
...
[propget, id(3), helpstring("Library version string")]
HRESULT Version([out, retval] BSTR* pResult);
...
};
[
uuid(...)
]
coclass About
{
[default] interface IAbout;
};
The registration
HKCR
{
MyLibrary.About.1 = s 'About MyLibrary'
{
CLSID = s '{...}'
}
MyLibrary.About = s 'About MyLibrary'
{
CLSID = s '{...}'
CurVer = s 'MyLibrary.About.1'
}
NoRemove CLSID
{
ForceRemove {...} = s 'Class About'
{
ProgID = s 'MyLibrary.About.1'
VersionIndependentProgID = s 'MyLibrary.About'
ForceRemove Programmable
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
TypeLib = s '{...}'
Version = s '1.0'
}
}
}
And the class
class ATL_NO_VTABLE CAbout :
public ATL::CComObjectRootEx<ATL::CComSingleThreadModel>,
public ATL::CComCoClass<CAbout, &CLSID_About>,
public ATL::ISupportErrorInfoImpl<&CLSID_About>,
public ATL::IDispatchImpl<IAbout, &IID_IAbout, &LIBID_MyLibrary, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
public:
CAbout()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_ABOUT)
DECLARE_NOT_AGGREGATABLE(CAbout)
BEGIN_COM_MAP(CAbout)
COM_INTERFACE_ENTRY(IAbout)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
...
STDMETHOD(get_Version)( /* [out, retval] */ BSTR* pResult );
...
};
OBJECT_ENTRY_AUTO(__uuidof(About), CAbout)
Any help with why it generates error 424 for test "is null"?