WinRT: Specifying RequestedTheme in XAML crashes unit test runner


If the RequestedTheme is specified inside markup of App.xaml, then MSTest test projects fail to run with the following errors:

Unhandled exception at 0x0FF66C57 (Windows.UI.Xaml.dll) in vstest.executionengine.appcontainer.x86.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x058ADAF8, 0x00000001).

Output window:
Exception has been thrown by the target of an invocation.

Windows event viewer:
Activation of the app a1864528-865b-4c7b-bf66-b13cba69fbe6_xczrxaf31gmnm!vstest.executionengine.x86.App for the Windows.Launch contract failed with error: The remote procedure call failed..

Stack trace:
combase.dll!RoFailFastWithErrorContextInternal(HRESULT hrError=0x8000ffff, unsigned long cStowedExceptions=1, _STOWED_EXCEPTION_INFORMATION_V1 * * aStowedExceptionPointers=0x058adaf8) Line 853 C++
Windows.UI.Xaml.dll!DirectUI::ErrorHelper::ProcessUnhandledErrorForUserCode(long)   Unknown
Windows.UI.Xaml.dll!DirectUI::DXamlCore::EnsureCoreApplicationInitialized(void) Unknown
Windows.UI.Xaml.dll!DirectUI::FrameworkView::Initialize(struct Windows::ApplicationModel::Core::ICoreApplicationView *) Unknown
twinapi.dll!5d8cb64f()  Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for twinapi.dll]   
twinapi.dll!5d8cbb23()  Unknown
twinapi.dll!5d8cb88e()  Unknown
SHCore.dll!748a59e1()   Unknown
kernel32.dll!76b08543() Unknown
ntdll.dll!7743ac69()    Unknown
ntdll.dll!7743ac3c()    Unknown

This occurs using both Visual Studio 2012 test runner and Resharper.

This does not happen if:
  • The application is declared as an <Application> (rather than CaliburnApplication)
  • The RequestedTheme is set inside the code-behind constructor
Replicated in NuGet package version 1.4 and latest source from 14 Jan 2013 (ad5acda9d1c3).

Repro attached

file attachments

Closed Jan 14, 2013 at 7:36 PM by NigelSampson
Not an issue with Caliburn Micro but the xaml framework in general.


NigelSampson wrote Jan 13, 2013 at 11:50 PM

From my investigation this doesn't appear to be a problem directly with Caliburn Micro but that the Unit Test Framework doesn't like any custom Application object used in conjunction with a Light RequestTheme .

markyoung wrote Jan 14, 2013 at 2:52 AM

According to http://msdn.microsoft.com/en-nz/library/windows/apps/windows.ui.xaml.application, this behaviour is invalid: "Other than the xmlns declarations and x:Class, no other attribute can appear on the Application root tag."

Internally, the RequestedTheme property is probably treated as a special case.

Frikki wrote May 18, 2014 at 9:32 PM

Actually, a similar error DEP0700 - The remote procedure call failed - happens without RequestedTheme, but with CaliburnApplication. It seems the use of some custom types, e.g., CaliburnApplication, in Xaml is incompatible with the WinRT unit test runner, because they don’t provide proper IXamlType interface implementations. See https://connect.microsoft.com/VisualStudio/feedback/details/790477/winrt-mstest-runner-fails-when-using-ilist-t-properties-of-custom-types-from-xaml

A workaround is to reference the binary from the file system instead of the app project.