I'm trying to use a Windows Runtime Component to provide interoperability between my Javascript UWP app and C# logic that I've written. If I set the minimum version to Fall Creator's Update (build 16299, needed to use .NET Standard 2.0 libraries), I get the following error when trying to call a simple method:
Unhandled exception at line 3, column 1 in ms-appx://ed2ecf36-be42-4c35-af69-93ec1f21c283/js/main.js
0x80131040 - JavaScript runtime error: Unknown runtime error
If I run this code using Creator's Update (15063) as the minimum, then the code runs fine.
I've created a Github repo containing a sample solution that generates the error for me when running locally.
Here's what main.js looks like. The error occurs when trying to run the getExample function:
// Your code here!
var test = new RuntimeComponent1.Class1;
test.getExample().then(result => {
console.log(result);
});
This is what Class1.cs looks like:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;
namespace RuntimeComponent1
{
public sealed class Class1
{
public IAsyncOperation<string> GetExample()
{
return AsyncInfo.Run(token => Task.Run(getExample));
}
private async Task<string> getExample()
{
return "It's working";
}
}
}
I can't think of a much simpler test case than that - I have no NuGet packages installed or anything like that. I have no idea what might be causing this. Anyone else have ideas?
Unknown runtime error
that I need an answer for. The exception is still thrown with these fixes applied. – Silkstocking