I am playing with Brokered UWP Component Project Templates (https://visualstudiogallery.msdn.microsoft.com/d2e9cac0-66a8-464a-a902-55ae765c8e6e), and testing if I can call asynchronous method from the brokered component.
So I replaced BrokeredComponent1 class :
namespace Server
{
public sealed class BrokeredComponent1
{
public string GetValue()
{
return "Hello .NET world";
}
}
}
by :
namespace Server
{
public sealed class BrokeredComponent1
{
public IAsyncOperation<string> GetValueAsync()
{
return Task.Run(() =>
{
Thread.Sleep(3000);
return "Hello .NET world";
}).AsAsyncOperation();
}
}
}
And then called it in MainPage in Button_Click method like this :
string brokeredComponentValue = await bc.GetValueAsync();
Everything seems to work in Debug Mode ("Hello .NET world" appears after 3 seconds), but I'm unable to make it work in Release Mode, app just crash when I click the button.
Any idea?
The problem was that UseDotNetNativeToolchain was default set to true in csproj in Realease mode.