Suave Nti
Suave Nti

Reputation: 3757

0x800401f3 Invalid Class String for COMInterop Dll

I have a C# Dll Registered as COM Interop:

[Guid("B41C2229-DBBD-4614-AE28-BFAE82B10F20")]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface ITestCls
    {
        [DispId(1)]
        string test(string input);
    }

    [Guid("5E88B6B8-AE17-40A0-917A-51DEBD818145")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("TestNm.TestCls")]       
    public class TestCls : ITestCls
    {
        public string test(string input)
        {
            Console.WriteLine("INSIDE CS :: ");
            return "CS ::  ARE YOU TESTING WITH THIS INPUT " + input;        
        }
    }

I tried to call the same from my C++ code :

    CoInitialize(NULL); 
    std::cout << data << '\n'; 
    _bstr_t bstrt(data);
    BSTR  lResult;  
    CComQIPtr<IWPrint> iWrapClass;
    HRESULT hresult;
    hresult = iWrapClass.CoCreateInstance(L"TestNm.TestCls");
    printf("0x%08lx", hresult); 
    if (SUCCEEDED (hresult))
    {
        iWrapClass->test(bstrt,&lResult);
        wprintf(L"Response  %s\n", lResult);
    }
    CoUninitialize();
    return lResult;

Everything works fine from my developer machine when I run the same from other machine HRESULT give me this :

 0x800401f3 

Am I missing some registering ?

Thanks

Upvotes: 2

Views: 6623

Answers (2)

noseratio
noseratio

Reputation: 61736

A few things to try while troubleshooting:

  • set the target CPU Platform for your managed assembly to x86 (32-bit);
  • make sure the assembly has a strong name;
  • on the target machine, use the 32-bit version of RegAsm.exe (C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe, not C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe).
  • register it on the target machine with RegAsm.exe /codebase (a strong assembly name is required for that).

Upvotes: 1

Related Questions