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

System.UnauthorizedAccessException when trying to start a Maui WinUI app with Mobile.BuildTools.Configuration #320

Open
BurkusCat opened this issue Jan 5, 2023 · 1 comment

Comments

@BurkusCat
Copy link

BurkusCat commented Jan 5, 2023

Description

Android + iOS Maui Mobile.BuildTools.Configuration seems to work fine! Trying to initialise the configuration manager/register the dependency causes an exception for WinUI.

Full error message:
System.UnauthorizedAccessException: 'Access to the path 'C:\WINDOWS\system32\Configuration' is denied.'

Reproduction Steps

Steps to reproduce the behavior:

  1. Add Mobile.BuildTools and Mobile.BuildTools.Configuration to a Maui project
  2. Add your app.config files as raw MauiAssets
  3. Register the ConfigurationManager instance with DI
  4. In the platform specific Window's App.xaml.cs, call ConfigurationManager.Init(true);

Expected Behavior

The WinUI app launches and the groundwork for using Mobile.BuildTools is setup

Actual Behavior

The app crashes on startup with an exception:
image

Removing the config code and only registering the ConfigurationManager.Current dependency:
image

When I try debugging inside the library, it appears to be using the CommonConfigManager which I think is the .NET Standard code path (intended for console apps/servers?).
image

One theory I have is that the library doesn't know about WinUI TargetFramework (https://github.com/dansiegel/Mobile.BuildTools/blob/master/src/Mobile.BuildTools.Configuration/Mobile.BuildTools.Configuration.csproj#L42) and is therefore not invoking any of the UWP code (would the UWP code work for WinUI?).

Environment

  • OS: Windows 11
  • IDE: VS2022
  • BuildTools Version: 2.0.245
  • IDE Version: 17.4.0
  • Build Target Framework: net6.0-windows10.0.19041.0

Reproduction App

https://github.com/BurkusCat/MbtConfigurationWinUIException

@dansiegel
Copy link
Owner

Well for starters WinUI isn't a supported or tested target. If you'd like to contribute to the project I'd be happy to have it support WinUI. But I can't promise timelines if you're waiting on me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants