Remote Procedure Call Failed (HRESULT: 0x800706BE)

Xie Steven 831 Reputation points
2024-11-20T06:48:49.1666667+00:00

The application uses diagnostic APIs to prevent it from starting repeatedly. However, it crashes on startup, and the following exception information is logged:

Remote procedure call failed.  (Exception from HRESULT: 0x800706BE)
   at System.Runtime.InteropServices.McgMarshal.ThrowOnExternalCallFailed(Int32, RuntimeTypeHandle) + 0x21
   at __Interop.ComCallHelpers.Call(__ComObject, RuntimeTypeHandle, Int32, Void*) + 0xbe
   at __Interop.ForwardComStubs.Stub_16[TThis](__ComObject, Int32) + 0x2e
   at Windows.System.Diagnostics.ProcessDiagnosticInfo.get_IsPackaged() + 0x18
   at cherApp.App.DetectDuplicateApp() + 0xdf
   at cherApp.App.<OnLaunched>d__19.MoveNext() + 0x2ce
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__7_0(Object) + 0x1e
   at System.Action`1.Invoke(T) + 0x28
   at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore() + 0x33
Cannot use RPC server.
   at System.Runtime.InteropServices.McgMarshal.ThrowOnExternalCallFailed(Int32, RuntimeTypeHandle) + 0x21
   at __Interop.ComCallHelpers.Call(__ComObject, RuntimeTypeHandle, Int32, Void*) + 0xbe
   at __Interop.ForwardComStubs.Stub_3[TThis, TResult](__ComObject, Int32) + 0x37
   at cherApp.App.DetectDuplicateApp() + 0x7d
   at cherApp.App.<OnLaunched>d__19.MoveNext() + 0x2ce
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__7_0(Object) + 0x1e
   at System.Action`1.Invoke(T) + 0x28
   at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore() + 0x33

What issues could cause this problem?

The code sample:

private bool DetectDuplicateApp()
{
    List<string> processNameCollection = new List<string>();
    IReadOnlyList<ProcessDiagnosticInfo> processes = new ProcessDiagnosticInfo.GetForProcesses();
    foreach(ProcessDiagnosticInfo process in processed)
    {
        if(process.IsPackaged)
       {
           processNameCollection .Add(process.ExecutableFileName);
       }
    }
    var count = processNameCollection .Where(item => item == "cherApp.exe");
    if(count > 1)
    {
          return false;   
    }
    return true;
}
Universal Windows Platform (UWP)
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.