Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinUI unknown exception when running as Project instead of MsixPackage #21794

Open
Tracked by #498
AndreasReitberger opened this issue Apr 12, 2024 · 4 comments
Open
Tracked by #498
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging platform/windows 🪟 s/needs-attention Issue has more information and needs another look s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@AndreasReitberger
Copy link

Description

I'm facing a problem while trying to release my app as Project on Windows.
When I start the application set as Project in the LaunchSettings

{
  "profiles": {
    "Windows Machine": {
      //"commandName": "MsixPackage",
      "commandName": "Project",
      "nativeDebugging": false
    }
  }
}
<!-- https://stackoverflow.com/a/75589936/10083577 -->
<WindowsPackageType Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">None</WindowsPackageType>
<WindowsAppSDKSelfContained Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">true</WindowsAppSDKSelfContained>
<WindowsAppSdkDeploymentManagerInitialize Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">false</WindowsAppSdkDeploymentManagerInitialize>
<!-- set false to build an exe file instead -->
<GenerateAppxPackageOnBuild>false</GenerateAppxPackageOnBuild>

I get an Microsoft.UI.Xaml.UnhandledException exception.

Value does not fall within the expected range.

Stacktrace:

bei WinRT.ExceptionHelpers.g__Throw|39_0(Int32 hr)
bei WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
bei ABI.Microsoft.Graphics.Canvas.ICanvasDrawingSessionMethods.DrawText(IObjectReference _obj, String text, Rect rectangle, Color color, CanvasTextFormat format)
bei Microsoft.Graphics.Canvas.CanvasDrawingSession.DrawText(String text, Rect rectangle, Color color, CanvasTextFormat format)
bei Syncfusion.Maui.Graphics.Internals.CanvasExtensions.DrawText(ICanvas canvas, String value, Rect rect, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, ITextElement textElement)
bei Syncfusion.Maui.Core.SfBusyIndicator.DrawTitle(ICanvas canvas)
bei Syncfusion.Maui.Core.SfBusyIndicator.OnDraw(ICanvas canvas, RectF dirtyRect)
bei Syncfusion.Maui.Core.SfView.Microsoft.Maui.Graphics.IDrawable.Draw(ICanvas canvas, RectF dirtyRect)
bei Syncfusion.Maui.Core.Platform.NativeGraphicsView.OnDraw(CanvasControl sender, CanvasDrawEventArgs args)
bei WinRT.EventSource_global__Windows_Foundation_TypedEventHandler_global__Microsoft_Graphics_Canvas_UI_Xaml_CanvasControl__global__Microsoft_Graphics_Canvas_UI_Xaml_CanvasDrawEventArgs.EventState.b__1_0(CanvasControl sender, CanvasDrawEventArgs args)
bei ABI.Windows.Foundation.TypedEventHandler`2.Do_Abi_Invoke[TSenderAbi,TResultAbi](Void* thisPtr, TSenderAbi sender, TResultAbi args)

image

When I switch back to MsixPackage, the app works. Same applies for Android.
Only WinUI as unpackaged built gives me this exception.

{
  "profiles": {
    "Windows Machine": {
      "commandName": "MsixPackage",
      //"commandName": "Project",
      "nativeDebugging": false
    }
  }
}
		<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
		<AppxBundle>Always</AppxBundle>
		<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>

image

I'm actually kinda lost how to debug the root-cause with this exception.
The only which popsup on the working configuration is this Binding issue, which I cannot identify in my project source code.

Schweregrad Anzahl Datenkontext Bindungspfad Ziel Zieltyp Beschreibung Datei Zeile Projekt
Fehler 1 Microsoft.UI.Xaml.Controls.SplitView TemplateSettings.CompactPaneGridLength Microsoft.UI.Xaml.Media.Animation.SplineDoubleKeyFrame.Value Double Converter failed to convert value of type 'Windows.Foundation.IReference`1<Microsoft.UI.Xaml.GridLength>' to type 'Double'

Maybe this is the reason why the Project build fails...

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.20 SR4

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

Publish as MsixPackage

Relevant log output

No response

@AndreasReitberger AndreasReitberger added the t/bug Something isn't working label Apr 12, 2024
@AndreasReitberger
Copy link
Author

AndreasReitberger commented Apr 15, 2024

I nailed it down to setting the FontFamily for the SfBusyControl.
If I remove the setter, it works. Seems to be an issue to find the font again, if released unpackaged.

Repro: https://github.com/AndreasReitberger/SfBusyIndicatorMauiIssue
Reported also to syncfusion: https://support.syncfusion.com/support/tickets/579453

Edit: Seems to be relevant to each syncfusion control if setting the FontFamily and publish unpackaged

@ninachen03
Copy link
Collaborator

Verified this issue with Visual Studio 17.10.0 Preview 3 (8.0.20 & 8.0.14).I can not repro this issue on windows machine.

@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 15, 2024
@PureWeen PureWeen added the s/needs-info Issue needs more info from the author label Apr 16, 2024
@AndreasReitberger
Copy link
Author

AndreasReitberger commented Apr 16, 2024

Verified this issue with Visual Studio 17.10.0 Preview 3 (8.0.20 & 8.0.14).I can not repro this issue on windows machine.

Are you able to publish the example as executable without a crash?
It does not work on my end.

I'm on Win11 if that matters.

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Apr 16, 2024
@AndreasReitberger
Copy link
Author

Syncfusion has verified this issue and found the root cause at CanvasTextFormat

microsoft/Win2D#941

@Eilon Eilon added the area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging platform/windows 🪟 s/needs-attention Issue has more information and needs another look s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants