Windows Runtime (WP 8) out of process component and raising / subscription events

0

I've made out-of-process WR/WP8 component with own background thread. It handles SIP stack internally and runs in background thread. It is modified code from ChatterBox MSDN example. https://code.msdn.microsoft.com/windowsapps/ChatterBox-VoIP-sample-app-b1e63b8b

Last days I add delegates to raise events from component. In C++/CX it is:

  public delegate void OnLogMessage(Platform::String^ msg);

  public ref class Logger sealed
  {

  public:

    Logger();
    virtual ~Logger();

    void FlushLog();

    event OnLogMessage^ OnLogMessage;
  };

There is subscription to event in C# code:

BackgroundProcessController.Instance.Logger.OnLogMessage += new   IntTalk.OnLogMessage(mLogger_OnLogMessage);

It builds ok.

But during debug I see exception:

A first chance exception of type 'System.Exception' occurred in mscorlib.ni.dll

Additional information: Interface not registered (Exception from HRESULT: 0x80040155)

If there is a handler for this exception, the program may be safely continued.

Proxy stub DLL is generated. I checked .h/.c files - they include some code for events.

What can be cause of this issue?

c++
events
windows-phone-8
out-of-process
asked on Stack Overflow Apr 10, 2015 by Dmytro

1 Answer

0

When debugging in native mode the same code I observed the "Interface not registered" exception. Short search resulted in this reference:

'Interface not Registered' error on ATL out-of-process callback interface

But I use C++/CX, no IDL at all. I checked the ChatterBox demo (which was starting point for my VoIP application) - they do not use Windows Runtime events at all.

So I stopped my attempts in this direction.

Another possible ways can be:

  • use queue of custom event structures, poll and handle this event from C# side.
  • use interface declared in C++/CX as event handler. Implement this interface on C# side. Not sure about if it will marshall events into main UI thread however.
answered on Stack Overflow Jun 3, 2015 by Dmytro • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0