• Upgrade your Internet Experience
  • Sign in
  • Microsoft.com
  • United States (English)
    Brasil (Português)Česká republika (Čeština)Deutschland (Deutsch)España (Español)France (Français)Italia (Italiano)Россия (Русский)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語)香港特别行政區 (中文)
 
 
.NET Framework Developer Center
 
 
Home
 
 
Library
 
 
Learn
 
 
Downloads
 
 
Support
 
 
Community
 
 
Forums
 
 
 
.NET Framework Developer Center > .NET Development Forums > Common Language Runtime > CoCreateInstance returns REGDB_E_CLASSNOTREG (IMAPI)
Ask a questionAsk a question
Search Forums:
  • Search Common Language Runtime Forum Search Common Language Runtime Forum
  • Search All .NET Development Forums Search All .NET Development Forums
  • Search All MSDN Forums Search All MSDN Forums
 

AnswerCoCreateInstance returns REGDB_E_CLASSNOTREG (IMAPI)

  • Tuesday, September 05, 2006 2:36 PMAlx_it Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    Hi, i'm trying to accessing IMAPI from a Managed C++ Windows Form Control Library

    the problem is that when i call CoCreateInstance  i get in return REGDB_E_CLASSNOTREG.
    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.
    i assume also that the class is correctly registered since the C# code works.
    thanks to anyone who try to help

    My C++/CLI code:
    [code]
    CLSIDFromString(L"{520CCA62-51A5-11D3-9144-00104BA11C5E}", &CLSID_MSDiscMasterObj);
    CLSIDFromString(L"{520CCA62-51A5-11D3-9144-00104BA11C5E}", &IID_IDiscMaster);

    CoInitialize( NULL );

    hr = CoCreateInstance(CLSID_MSDiscMasterObj, nullptr, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IDiscMaster, (void**)&m_pDiscMaster); //REGDB_E_CLASSNOTREG
    [/code]


    working C# code
    [code]
    object discMaster = null;
    Guid clsIdDiscMaster = new Guid(CLSID_MSDiscMasterObj);
    Guid iidDiscMaster = new Guid(IID_IDiscMaster);
    int hResult = IMAPIObjectFactory.CoCreateInstance(ref clsIdDiscMaster, IntPtr.Zero, CLSCTX.CLSCTX_INPROC_SERVER | CLSCTX.CLSCTX_LOCAL_SERVER, ref iidDiscMaster, out discMaster);
    [/code]

    where CoCreateInstance is
    [code]
            [DllImport("ole32", CharSet = CharSet.Unicode)]
            private extern static int CoCreateInstance(
                ref Guid CLSID,
                IntPtr pUnkOuter,
                CLSCTX dwClsContext,
                ref Guid IID,
                [MarshalAs(UnmanagedType.Interface)]
                out object ppv);
    [/code]
    • ReplyReply
    • QuoteQuote
     

Answers

  • Tuesday, September 05, 2006 3:14 PMAlx_it Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Vote As Helpful
    0
    IMAPIObjectFactory only encapsulate CoCreateinstance nothing more.
    anyway i tried changed

    From:
    CoCreateInstance(CLSID_MSDiscMasterObj, 0, CLSCTX_ALL, IID_IDiscMaster, (void**)&m_pDiscMaster); //REGDB_E_CLASSNOTREG

    To:
    CoCreateInstance(__uuidof(MSDiscMasterObj), 0, CLSCTX_ALL, IID_IDiscMaster, (void**)&m_pDiscMaster); //OK

    it seems to solve the problem...thx




    • ReplyReply
    • QuoteQuote
     

All Replies

  • Tuesday, September 05, 2006 2:45 PMnobugzMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    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.

    • ReplyReply
    • QuoteQuote
     
Need Help with Forums? (FAQ)
 
© 2009 Microsoft Corporation. All rights reserved.
Terms of Use
|
Trademarks
|
Privacy Statement