Cant load WinRT/C++ component to my UWP/C# application
Asked Answered
G

0

6

I need to wrap WebRTC c++ library into WinRT component and use it from my UWP/C# application. There is a good article how to use native c++ in uwp which describes all the integration steps, which I followed. Briefly:

  • I have created Dll/C++ DLL1 library and linked my static library libwebrtc_full.a. Made all necessary calls
  • Then, I referenced the DLL in my WinRT/C++ project WindowsRuntimeComponent1 and created public ref class MyClass successfully which makes all the necessary calls from DLL1
  • My UWP app App1 sees MyClass correctly and its public methods, App1 has reference to the WindowsRuntimeComponent.

When it comes to run the application, I am getting runtime exception as soon as I try to use one of the classes implemented in WindowsRuntimeComponent1

The specified module could not be found.
(Exception from HRESULT: 0x8007007E)

I created and uploaded a sample project to reproduce my problem to GDrive I included my static libwebrtc.a as well in the sample project in case if its the root cause of the problem.

I already went through the similar questions on SO and most similar to my problem is this one. The difference is that I am referencing the project and still get the same exception.

EDIT1:

This is how MyClass looks like:

namespace WindowsRuntimeComponent1
{
    public ref class MyClass sealed
    {
    public:
        MyClass(int sampleRate);
        virtual ~MyClass();

        void ProcessFrame(const Platform::Array<short>^ mic, const Platform::Array<short>^ speaker, const Platform::Array<short>^ output);

    private:
        void* p;
    };
}

EDIT2: I ran gflags App1.exe +sls as suggested in the comments, but I dont see what dependency is missing. Below is the screenshot with stack trace:

enter image description here

Gorcock answered 1/6, 2021 at 5:2 Comment(9)
"created public ref class MyClass" - That doesn't sound like C++/WinRT. What programming language are you really using?Tillo
@Tillo I edited my answer and attached .h of MyClass which is CLR, I guessGorcock
There is no CLR in the Windows Runtime. Pretty hard to drive that point home, even ten years after the Windows Runtime was introduced. The programming language you are using is C++/CX. Like C++/WinRT (which you aren't using) this compiles down to native code.Tillo
@Tillo thanks for clarifying this moment. So, is it possible what I am trying to achieve - use C++/CX wrapper class in my UWP/c# project?Gorcock
So long as the Windows Runtime Component doesn't use APIs that aren't available for your target platform (UWP) that's perfectly fine. I don't know whether WebRTC provides an implementation that can run on the UWP, and if it doesn't whether this is related to the issue. It's likely, though, that you are simply missing a dependency in your package.Tillo
May I ask you to install the sample project I attached in the question? I can post it to GitHub, if its more convenient for youGorcock
I don't have any .NET workloads installed, so that's not going to work for me. What you can do to investigate further is to enable loader snaps, and run the application under a debugger. That might give you insights into which dependency is failing to load.Tillo
@Tillo I have run the gflags utility with +sls argument, could you please have a look into screenshot, I can not see which dependency is missingGorcock
You need to copy protobuf_lite.dll into the deployment directory (aside app1.exe in bin\x86\Debug\AppX)Bonnette

© 2022 - 2024 — McMap. All rights reserved.