C++/WinRT Problems Calling C#/WinRT Method

JRH3221 0 Reputation points

I was following the tutorial Authoring a C# Windows Runtime component for use from a C++/WinRT app, it compiles correctly with no issues, but before the program properly initializes it crashes.

The exception thrown is "Microsoft C++ exception: winrt::hresult_error at memory location", the hresult value upon the debugger break, is "0x80131040 : The located assembly's manifest definition does not match the assembly reference."

I checked the Nuget packages to make sure they are all up to date, as well as visual studio itself. Both the UWP and the WinRT project are targeting the same windows version, so i'm out of ideas on how to resolve this issue.

This issue only occurs when i have the line"winrt::SampleComponent::Example myExample;" in my header file. As mentioned before, everything is seemingly fine at compile time, with the c# namespace and class being recognized, it's just when the program opens things go wrong.

Universal Windows Platform (UWP)
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,946 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,441 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JRH3221 0 Reputation points

    I figured out the issue after re-reading the tutorial. In a note box it says to "On the New Universal Windows Platform Project dialog box, choose Windows 10 Creators Update (10.0; Build 15063) as the Minimum Version.", I didn't think this was necessary as i was targeting a higher minimum version. Now i wonder why needing support for a lower version would be necessary, as newer version should include everything that is in the previous?

    0 comments No comments