Не могу заставить работать перечисление в коллекции. Имеются два класса: коллекции и соответствующего enumerator'а. Обычные методы работают нормально, но при попытке из VB перечислить элементы конструкцией for each выводит комовскую ошибку "Run-time error '-2147319779 (8002801d)': Automation error. Library not registered." Может дело в объявлении классов в idl?! Подскажите, пожалуйста, куда копать.
// IAttributeList
[
object,
uuid("929C0533-B0C3-4DB7-9A1B-1386F01DDEC3"),
dual, helpstring("IAttributeList Interface"),
pointer_default(unique),
oleautomation, nonextensible
]
__interface IAttributeList : IDispatch
{
[restricted, local] STDMETHOD_(void*, _GetListObject)();
[id(0x300), helpstring("method Count")] STDMETHOD(Count)([out, retval] long *Size);
[id(0x301), helpstring("method Remove")] STDMETHOD(Remove)([in] BSTR Key);
[id(0x302), helpstring("method Remove")] STDMETHOD(RemoveAt)([in] LONG Index);
[id(0x303), helpstring("method RemoveAll")] STDMETHOD(RemoveAll)();
[id(0x304), helpstring("method IsExists")] STDMETHOD(IsExists)([in] BSTR Key, [out, retval] VARIANT_BOOL *Flag);
[id(0x305), helpstring("method Copy")] STDMETHOD(Copy)([in] IAttributeList* List);
[id(0x306), helpstring("method Join")] STDMETHOD(Join)([in] IAttributeList* List);
[id(0x307), helpstring("method IndexOf")] STDMETHOD(IndexOf)([in] BSTR Key, [out, retval] long *Index);
[id(0x308), helpstring("method KeyOf")] STDMETHOD(KeyOf)([in] long Index, [out, retval] BSTR *Key);
[propget, id(0x309), helpstring("property At")] STDMETHOD(At)([in] LONG Index, [out, retval] VARIANT *Value);
[propput, id(0x309), helpstring("property At")] STDMETHOD(At)([in] LONG Index, [in] VARIANT Value);
[propget, id(DISPID_VALUE), helpstring("property Item")] STDMETHOD(Item)([in] BSTR Key, [out, retval] VARIANT *Value);
[propput, id(DISPID_VALUE), helpstring("property Item")] STDMETHOD(Item)([in] BSTR Key, [in] VARIANT Value);
[id(DISPID_NEWENUM), restricted] STDMETHOD(_NewEnum)([out, retval] IUnknown **pVal);
};
// CAttributeList
[
coclass,
threading("apartment"),
support_error_info("IAttributeList"),
vi_progid("ActiveSWF2.AttributeList"),
progid("ActiveSWF2.AttributeList.1"),
version(1.0),
uuid("8C70F716-2CFF-4FF9-B0D0-F0273A65F84E"),
helpstring("AttributeList Class")
]
class ATL_NO_VTABLE AttributeList :
public AttributeListImpl <AttributeList, IAttributeList>
{
public:
AttributeList()
{
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
STDMETHOD_(void *, _GetListObject)();
protected:
ParamList m_List;
};
// ....
STDMETHODIMP _NewEnum(/*[out, retval]*/ IUnknown **pVal)
{
return AttributesListEnum::CreateInstanceInit(pVal, this);
}
// AttributesListEnum
[
coclass,
threading("apartment"),
support_error_info("IEnumVARIANT"),
vi_progid("ActiveSWF2.AttributesListEnum"),
progid("ActiveSWF2.AttributesListEnum.1"),
version(1.0),
uuid("97B2A8A2-5329-467d-BCB0-01F0E81869B5"),
helpstring("AttributesListEnum Class"),
implements("IEnumVARIANT"),
hidden
]
class ATL_NO_VTABLE AttributesListEnum :
public IEnumVARIANT
{
public:
AttributesListEnum()
{
m_Index = 0;
m_iList = NULL;
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
STDMETHOD(Next)(/*[in]*/ ULONG celt, /*[out]*/ VARIANT *rgVar, /*[out]*/ ULONG *pCeltFetched);
STDMETHOD(Skip)(/*[in]*/ ULONG celt);
STDMETHOD(Reset)(void);
STDMETHOD(Clone)(/*[out]*/ IEnumVARIANT **ppEnum);
public:
template <class _TI> static HRESULT CreateInstanceInit(_TI** pp, IAttributeList* _list, ULONG _index = 0)
{
HRESULT hRes;
AttributesListEnum *p;
ATLTRY(p = new CComObject<AttributesListEnum>)
hRes = E_OUTOFMEMORY;
if (p != NULL)
{
p->SetVoid(NULL);
hRes = p->_AtlFinalConstruct();
if (SUCCEEDED(hRes))
hRes = p->QueryInterface(__uuidof(_TI), (void**)pp);
if (SUCCEEDED(hRes))
{
p->m_iList = _list;
p->m_Index = _index;
}
else
{
delete p;
}
}
return hRes;
}
protected:
CComPtr<IAttributeList> m_iList;
ULONG m_Index;
};
#line 31 "e:\\work.cps\\activeswf2\\modules\\aswfcom\\src\\attributelistenum.h"
coclass AttributesListEnum {
interface IEnumVARIANT;
};
[
version(1.0),
uuid(8C70F716-2CFF-4FF9-B0D0-F0273A65F84E),
helpstring("AttributeList Class")
]
#line 57 "e:\\work.cps\\activeswf2\\modules\\aswfcom\\src\\attributelist.h"
coclass AttributeList {
interface IAttributeList;
};
[
version(1.0),
uuid(959D4F04-4D9F-41BC-A374-03FA2F019508),
helpstring("Children Class"),
hidden
]