locked
"Class not registered" (0x80040154) when using custom COM component from Windows RT component

    Question

  • I know that only some system provided COM components are available or WinRT component. Now, I'm creating a new WinRT component and would like to call my in-house COM component. This in-house component is just a test, pretty simple, an interface with a single method to return a string. However, in my WinRT component, "Class not registered" error returned all the time whenever to get the instance of that component. The question is, is it available to call COM component from WinRT component? Thanks.

    Here is interface definition of COM component. (a in-process DLL)
    
    interface __declspec(uuid("C57A8CA5-1C97-447e-9176-BAB222D8EDCB"))
    IGardenInfo : public IUnknown
    {
    	virtual HRESULT __stdcall GardenName(BSTR *strName) = 0;
    };
    
    
    In my WinRT component, codes to create instance of that COM component 
    
    
    namespace mycomp
    {
            // delegates
    
        // Activatable class.
        public ref class LangSample sealed
        {
    
    		IGardenInfo* m_pGI;
    		IGarden *m_pG;
    		Platform::String^ m_GardenName;
    		Platform::String^ m_GardenTitle;
    		int nRetCode;
        public:
            LangSample()
    	{
    			nRetCode = 0;
    			HRESULT hRes = S_OK;
    			
    			hRes = ::CoCreateInstance(CLSID_Garden, 0, 0, __uuidof(IGardenInfo), (void**)&m_pGI);
    
    			if (hRes != S_OK)
    			{
    				m_GardenName = "Win32 Garden Name failed, allocated in WINRT";
    				nRetCode = hRes;
    			}
    			else
    			{
    				BSTR str = SysAllocString(L"GardenName-WinRT");
    				m_pGI->GardenName(&str);
    				m_GardenName = ref new Platform::String(str);
    			}
    			hRes = ::CoCreateInstance(CLSID_Garden, 0, 0, __uuidof(IGarden), (void**)&m_pG);
    
    			if (hRes != S_OK)
    			{
    				m_GardenTitle = "Win32 Garden Info failed, allocated in WINRT";			
    			}
    			else
    			{
    				BSTR str = SysAllocString(L"GardenTitle-WinRT");
    				m_pG->GetInfo(&str);
    				m_GardenTitle = ref new Platform::String(str);
    			}
            }
    

     

    Tuesday, January 17, 2012 3:12 AM

All replies

  • You can call custom COM components, but they have to be registration free and included in your app package.

    --Rob

    Tuesday, January 17, 2012 7:16 AM
    Owner
  • Rob, Thanks.

    I'm confused, do you mean that I have to use my COM component as a normal DLL? or should my WinRT component link COM DLL statically? If that is so, how Microsoft provides those system provided COM components? are they also wrapped in WinRT component? Thanks.

     

     

    Tuesday, January 17, 2012 5:58 PM