How to call windows runtime component from c++/cx uwp project?

1

I created a C# runtime component based on Visual Studio template in the same solution with my C++/CX UWP project:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace httpServer
{
    public sealed class Class1
    {
        public int SampleProperty { get; set; }
    }
}

I added the reference to component to my C++/CX UWP project and created object as follows:

auto srv = ref new httpServer::Class1();

Solution compiles, but on this line I get an exception:

Exception thrown at 0x776A3DB2 in Bonsai Master UWP.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x05598104.

onecore\com\combase\objact\dllcache.cxx(4713)\combase.dll!75CF6DE2: (caller: 75CFE2BB) ReturnHr(1) tid(8408) 80131040 Exception thrown at 0x776A3DB2 (KernelBase.dll) in Bonsai Master UWP.exe: WinRT originate error - 0x80131040 : 'The text associated with this error code could not be found.'.

c#
uwp
c++-cx
asked on Stack Overflow Feb 20, 2020 by Andrey • edited Jun 20, 2020 by Community

1 Answer

0

It looks like a bug in Visual Studio: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/6d0d04e8-1471-4343-a78e-65c6405080cc/winrt-component-works-in-c-but-not-in-c?forum=wpdevelop

I checked VS 2017 and VS 2019: the error appears in the both.

answered on Stack Overflow Feb 20, 2020 by Andrey • edited Feb 21, 2020 by Andrey

User contributions licensed under CC BY-SA 3.0