2

I am trying to use a COM server generated by Visual Studio 2010 . When I run CreateInstance(..) , I get error code 0x80040154 . I enabled fusion log and ran fuslogvw . Fuslogvw reported that loading of assembly (by unknown caller assembly)

mscorlib.resources, Version=4.0.0.0, Culture=zh-HK, PublicKeyToken=b77a5c561934e089

I have already installed .net framework 4 language pack for traditional chinese and also simplified chinese .

Please help . Thanks in advance.

My c++ code is as follow:

#include "stdafx.h"
#import "/Project/TestCOM/MyProject.tlb"
#include <comutil.h>

int _tmain(int argc, _TCHAR* argv[])
{
    CoInitialize(NULL);

    MyProject::_PHPStarterPtr pCalc;

    HRESULT hRes = pCalc.CreateInstance(__uuidof(MyProject::PHPStarter));
    if(FAILED(hRes)) 
    {
        printf("MyProject::_PHPStarterPtr failed w/err 0x%08lx\n", hRes); // it printed MyProject::_PHPStarterPtr failed w/err 0x80040154
    }
    else
    {
        pCalc->AddRef();

        bstr_t s("hello");
        bstr_t outStr = pCalc->Echo(s);
        printf("outStr = %s\n", (const char *)outStr);

        pCalc->Release();
        printf("Dispose() done\n");
    }

    CoUninitialize();
    return 0;
}
2
  • 1
    Maybe you are mixing 32/64 bits images? (for instance you are running on a x64 box and your app differs from your component int the target architecture) Commented May 15, 2012 at 22:41
  • turned out that one xml config missing and a bunch of other problems. It was my fault . Thanks for your suggestion. Commented May 18, 2012 at 1:59

1 Answer 1

3

0x80040154 means "class not registered". To register COM components inside .NET assemblies, you use regasm.exe tool from the .NET framework directory. It can be done manually, or as a custom post-build step.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your suggestion on regasm. I tried that . In the end it was my fault to forget copying a xml config file , which fuslogvw does not tell me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.