none
C# COM Client calls C++ COM Server, exception :The RPC server is unavailable RRS feed

  • Question

  • Here is C# COM Client application to call C++ Com server (it is a Windows Service exe), It will throw following exception:

    System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
       at ServiceClass.GetStatus(String bstrProjName, UInt16 wSchID, UInt16 wEvID, String& pbstrStatus, Int32& peState)

    This issue could not be duplicated by 100%. But if run the C# application for several weeks, the issue will appear a few times.

    1 C# client:
    1.1
    public void VerificationStatusUpdate(out string Status)
      {
                int newState = 0;
                Status = string.Empty;        
                this.service.GetStatus(string.Empty, 1, 1, out AgentStatus, ref newState); // throw RPC Exception
       }

    1.2 the Interop.cs file
    public virtual extern void GetStatus([MarshalAs(UnmanagedType.BStr)] string bstrProjName, ushort wSchID, ushort wEvID, [Out][MarshalAs(UnmanagedType.BStr)] out string pbstrStatus, ref int peState);

    2 C++ Server
    2.1 Service.idl file:
    [id(20), helpstring("method GetStatus")] HRESULT GetStatus(BSTR bstrProjName, WORD wSchID, WORD wEvID, BSTR* pbstrStatus, int* peState);

    2.1 the cpp file:
    STDMETHODIMP CService::GetStatus(BSTR bstrProjName, WORD wSchID, WORD wEvID, BSTR *pbstrStatus, int *peState)
    {
    ....
    }

    What causes "The RPC server is unavailable" exception?

    Are there any risk in above C# Client and C++ Server code?

    Thanks

    Scott

    Wednesday, July 10, 2013 7:39 AM

Answers

  • You should also check that the server is not busy doing something else as if it does not return in a timely manner this error will be generated.

    Friday, July 12, 2013 12:41 AM
  • Hi ,

    can you check if the  Remote Procedure Call (RPC) Service is running in the control panel /services

    Regards,

    Anant

    Wednesday, July 10, 2013 4:58 PM

All replies

  • Hi ,

    can you check if the  Remote Procedure Call (RPC) Service is running in the control panel /services

    Regards,

    Anant

    Wednesday, July 10, 2013 4:58 PM
  • You should also check that the server is not busy doing something else as if it does not return in a timely manner this error will be generated.

    Friday, July 12, 2013 12:41 AM