The code below results in this exception even with an empty XML(only the page tag):
Natvis C++/WinRT: Exception in cppwinrt_visualizer::EvaluateVisualizedExpression
Natvis C++/WinRT: Exception in cppwinrt_visualizer::EvaluateVisualizedExpression
Natvis C++/WinRT: Exception in cppwinrt_visualizer::EvaluateVisualizedExpression
Natvis C++/WinRT: Exception in cppwinrt_visualizer::EvaluateVisualizedExpression
The error happens on this line rootFrame.Navigate(xaml_typename<ProjectNamespace::FirstPage>(), box_value(e.Arguments()));
void App::OnLaunched(LaunchActivatedEventArgs const& e)
{
window = make<MainWindow>();
Frame rootFrame = Frame();
rootFrame.NavigationFailed({this, &App::OnNavigationFailed});
rootFrame.Navigate(xaml_typename<ProjectNamespace::FirstPage>(),
box_value(e.Arguments()));
window.Content(rootFrame);
window.Activate();
}
Any idea what could be the problem?
The diagnostic message doesn't indicate a problem with the code. It originates in C++/WinRT's debug visualizer implementation attempting to supply human-readable insights to the debugger. This is the faulting function:
HRESULT cppwinrt_visualizer::EvaluateVisualizedExpression(...)
{
try
{
// ...
}
catch (...)
{
// If something goes wrong, just fail to display object/property. Don't take down VS.
NatvisDiagnostic(pVisualizedExpression,
L"Exception in cppwinrt_visualizer::EvaluateVisualizedExpression", NatvisDiagnosticLevel::Error, to_hresult());
return E_FAIL;
}
}
The comment suggests this is a known issue but hasn't been fully fixed. Damage is contained, and instead of crashing the debugger, this function doesn't visualize an object or property if it finds that it can't, for any number of reasons.
This is enough information to construct a repro:
App::OnLaunched()
on this line:
🔴 window = make<MainWindow>();
At this point, the "Debug" output pane will show several errors like the following:
Natvis C++/WinRT: Exception in cppwinrt_visualizer::EvaluateVisualizedExpression
Since the issue is inside the C++/WinRT debug visualizer implementation, there's nothing we can do to fix it. It would need to be addressed by one of the Windows App SDK, MSBuild, or C++/WinRT teams. Given past experience with problems where XAML and C++/WinRT meet, I'm reluctant to even file an issue.
Users are left with two options:
Natvis C++/WinRT:
.