CoCreateInstance returns REGDB_E_CLASSNOTREG (IMAPI)Hi, i'm trying to accessing IMAPI from a Managed C++ Windows Form Control Library<br> <br> the problem is that when i call CoCreateInstance  i get in return REGDB_E_CLASSNOTREG.<br> I Really dont understand why since the equivalent code from a .NET imapi wrapper that works is identical. notice also that the same C++ code here works on another machine.<br>i assume also that the class is correctly registered since the C# code works.<br>thanks to anyone who try to help<br> <br> My C++/CLI code:<br> [code]<br> CLSIDFromString(L&quot;{520CCA62-51A5-11D3-9144-00104BA11C5E}&quot;, &amp;CLSID_MSDiscMasterObj);<br> CLSIDFromString(L&quot;{520CCA62-51A5-11D3-9144-00104BA11C5E}&quot;, &amp;IID_IDiscMaster);<br> <br> CoInitialize( NULL );<br> <br> hr = CoCreateInstance(CLSID_MSDiscMasterObj, nullptr, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IDiscMaster, (void**)&amp;m_pDiscMaster); //REGDB_E_CLASSNOTREG<br> [/code]<br> <br> <br> working C# code<br> [code]<br> object discMaster = null;<br> Guid clsIdDiscMaster = new Guid(CLSID_MSDiscMasterObj);<br> Guid iidDiscMaster = new Guid(IID_IDiscMaster);<br> int hResult = IMAPIObjectFactory.CoCreateInstance(ref clsIdDiscMaster, IntPtr.Zero, CLSCTX.CLSCTX_INPROC_SERVER | CLSCTX.CLSCTX_LOCAL_SERVER, ref iidDiscMaster, out discMaster);<br> [/code]<br> <br> where CoCreateInstance is<br> [code]<br>         [DllImport(&quot;ole32&quot;, CharSet = CharSet.Unicode)]<br>         private extern static int CoCreateInstance(<br>             ref Guid CLSID,<br>             IntPtr pUnkOuter,<br>             CLSCTX dwClsContext,<br>             ref Guid IID,<br>             [MarshalAs(UnmanagedType.Interface)]<br>             out object ppv);<br> [/code]© 2009 Microsoft Corporation. All rights reserved.Thu, 19 Jun 2008 00:15:52 Zc234f02a-ba13-4c8a-9e76-a633bdbd742bhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/c234f02a-ba13-4c8a-9e76-a633bdbd742b#c234f02a-ba13-4c8a-9e76-a633bdbd742bhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/c234f02a-ba13-4c8a-9e76-a633bdbd742b#c234f02a-ba13-4c8a-9e76-a633bdbd742bAlx_ithttp://social.msdn.microsoft.com/Profile/en-US/?user=Alx_itCoCreateInstance returns REGDB_E_CLASSNOTREG (IMAPI)Hi, i'm trying to accessing IMAPI from a Managed C++ Windows Form Control Library<br> <br> the problem is that when i call CoCreateInstance  i get in return REGDB_E_CLASSNOTREG.<br> I Really dont understand why since the equivalent code from a .NET imapi wrapper that works is identical. notice also that the same C++ code here works on another machine.<br>i assume also that the class is correctly registered since the C# code works.<br>thanks to anyone who try to help<br> <br> My C++/CLI code:<br> [code]<br> CLSIDFromString(L&quot;{520CCA62-51A5-11D3-9144-00104BA11C5E}&quot;, &amp;CLSID_MSDiscMasterObj);<br> CLSIDFromString(L&quot;{520CCA62-51A5-11D3-9144-00104BA11C5E}&quot;, &amp;IID_IDiscMaster);<br> <br> CoInitialize( NULL );<br> <br> hr = CoCreateInstance(CLSID_MSDiscMasterObj, nullptr, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IDiscMaster, (void**)&amp;m_pDiscMaster); //REGDB_E_CLASSNOTREG<br> [/code]<br> <br> <br> working C# code<br> [code]<br> object discMaster = null;<br> Guid clsIdDiscMaster = new Guid(CLSID_MSDiscMasterObj);<br> Guid iidDiscMaster = new Guid(IID_IDiscMaster);<br> int hResult = IMAPIObjectFactory.CoCreateInstance(ref clsIdDiscMaster, IntPtr.Zero, CLSCTX.CLSCTX_INPROC_SERVER | CLSCTX.CLSCTX_LOCAL_SERVER, ref iidDiscMaster, out discMaster);<br> [/code]<br> <br> where CoCreateInstance is<br> [code]<br>         [DllImport(&quot;ole32&quot;, CharSet = CharSet.Unicode)]<br>         private extern static int CoCreateInstance(<br>             ref Guid CLSID,<br>             IntPtr pUnkOuter,<br>             CLSCTX dwClsContext,<br>             ref Guid IID,<br>             [MarshalAs(UnmanagedType.Interface)]<br>             out object ppv);<br> [/code]Tue, 05 Sep 2006 14:36:42 Z2006-09-05T15:14:57Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/c234f02a-ba13-4c8a-9e76-a633bdbd742b#60bf3e68-98a0-4208-b2a3-4b7ab7e68a5fhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/c234f02a-ba13-4c8a-9e76-a633bdbd742b#60bf3e68-98a0-4208-b2a3-4b7ab7e68a5fnobugzhttp://social.msdn.microsoft.com/Profile/en-US/?user=nobugzCoCreateInstance returns REGDB_E_CLASSNOTREG (IMAPI)<font size=2><span style="font-family:verdana,geneva,arial,sans-serif">It is not equivalent code.  In the C# code, you ask IMAPIObjectFactory to create the class object for you.  You need to duplicate that in C++, find out how to create the IMAPIObjectFactory object.<br> <br> </span></font>Tue, 05 Sep 2006 14:45:32 Z2006-09-05T14:45:32Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/c234f02a-ba13-4c8a-9e76-a633bdbd742b#91205a05-2553-488c-8f68-7977aeb875cdhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/c234f02a-ba13-4c8a-9e76-a633bdbd742b#91205a05-2553-488c-8f68-7977aeb875cdAlx_ithttp://social.msdn.microsoft.com/Profile/en-US/?user=Alx_itCoCreateInstance returns REGDB_E_CLASSNOTREG (IMAPI)<span><span id="_ctl0_MainContent__ctl0_PostForm_ReplyBody" class=txt4><font size=2><span style="font-family:verdana,geneva,arial,sans-serif">IMAPIObjectFactory only encapsulate CoCreateinstance nothing more.<br>anyway i tried changed<br><br>From:<br>CoCreateInstance(CLSID_MSDiscMasterObj, 0, CLSCTX_ALL, IID_IDiscMaster, (void**)&amp;m_pDiscMaster); //REGDB_E_CLASSNOTREG<br><br>To:<br>CoCreateInstance(__uuidof(MSDiscMasterObj), 0, CLSCTX_ALL, IID_IDiscMaster, (void**)&amp;m_pDiscMaster); //OK<br><br>it seems to solve the problem...thx<br><br><br><br><br></span></font></span></span>Tue, 05 Sep 2006 15:14:50 Z2006-09-05T15:14:57Z