CreateInstance() fails with error code 1008 in C++ COM

Posted on 2014-08-23
Last Modified: 2014-09-02
Visual Studio 2010 ULTIMATE - To create both server and client.

Module name : Server
Component Name: Maths

I'm trying the following to use the com component.


IMathsPtr ptr;
HRESULT hr = ptr.CreateInstance("Server.Maths"); // To create  the co object.
// here I am getting Invalid class string - during debugging

Open in new window

I have registered the COM component in the registry. During building Server app, it automatically registers.
Also tried with regsvr32 to register.
But here my Question is how to get the valid class string fro registry or any other way.
In Visual studio 2010 ultimate, I am not finding any option for OLE Object viewer!!!

Any body having any point on this, please share.

FYI: I searched this in registry, couldn't find.

    LVL 86

    Expert Comment

    Stupif question - what does 'CoInitialize()' return? Chances are that this call returns an error condition and that 'ERROR_NO_TOKEN' (1008) is unrelated.
    LVL 8

    Author Comment

    by:Subrat (C++ windows/Linux)
    CoInitialize() is Success.
    LVL 8

    Accepted Solution

    In visuAL STUDIO 2010, it's not generating progid/CLSID as modulename.componentname ex:Server.Maths here.
    So I was getting error in client while trying to use this progid.

    Create progid mannually during creation of ATL Simple COM Object, solves the problem.
    LVL 8

    Author Closing Comment

    by:Subrat (C++ windows/Linux)
    Root cause and soln is provided.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    One of the most frequent problems a "newbie" developer may encounter is having to deal with different data formats. One for all: THE DATE We, as humans, need to "see" a date and then interpret it (much of the times this is an automatic operation)…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now