Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

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

$
0
0

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


Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>