none
[UWP]Designer error: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) RRS feed

  • Question

  • I have been having this problem for a long time (more  than one year).

    MainWindow.xaml looks like this:

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <SplitView x:Name="splitView" IsPaneOpen="True" DisplayMode="CompactOverlay" OpenPaneLength="475"
                    CompactPaneLength="50" PaneClosed="splitView_PaneClosed" PaneClosing="splitView_PaneClosing">
                <SplitView.Pane>
                    <Grid x:Name="settingsPane">
                        <Button x:Name="btnTogglePane" x:Uid="btnTogglePane" Width="50" Height="50"
                                ToolTipService.ToolTip="Settings" Click="btnTogglePane_Click" HorizontalAlignment="Left"
                                VerticalAlignment="Top" BorderThickness="0" Background="{x:Null}">
                            <Image Source="Images/Settings_32x.png" />
                        </Button>
                        <local:SettingsPanel x:Name="settingsPanel" />
                    </Grid>
                </SplitView.Pane>
                <local:GalleryControl x:Name="galleryControl" />
            </SplitView>
        </Grid>

    Most of the time, Visual Studio designer gives me an error page that says "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))". However, the app runs correctly on my dev machine.

    Is this a known problem?



    Ignorance is blissful

    Monday, September 9, 2019 5:01 PM

All replies

  • Hi,

    Could you please tell me which version of Visual Studio you are using? I tried your XAML code in a blank app, but the XAML designer shows correctly(I created two blank usercontrol called SettingsPanel and GalleryControl). I'm using VS2019, version 16.2.4.  The problem seems to be more related to the Visual Studio tool. I'd suggest you to report a problem for the Visual Studio. Click the Help button on the Top bar and Select Send Feedback and then choose Report a Problem

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 10, 2019 1:42 AM
    Moderator
  • Thanks a lot for your effort to verify my code. I finally successfully devised a reliable repro. It seems it's related to UserControl's SizeChanged event.

    The  detailed error is:

    System.Exception: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
    
       at Windows.UI.Xaml.Controls.Image.put_Source(ImageSource value)
       at UWPTestApp.TestUserControl.UserControl_SizeChanged(Object sender, SizeChangedEventArgs e

    MainPage.xaml:

    <Page
        x:Class="UWPTestApp.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:UWPTestApp"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <Grid>
            <local:TestUserControl x:Name="uc1" />
        </Grid>
    </Page>

    TestUserControl.xaml:

    <UserControl
        x:Class="UWPTestApp.TestUserControl"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:UWPTestApp"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        d:DesignHeight="300"
        d:DesignWidth="400"
        SizeChanged="UserControl_SizeChanged">
    
        <Grid>
            <Image Name="img" />
        </Grid>
    </UserControl>

    TestUserControl.xaml.cs:

    public sealed partial class TestUserControl : UserControl
        {
            static BitmapImage OKImage = new BitmapImage(new Uri("ms-appx:///Images/OK.png"));
    
            public TestUserControl()
            {
                this.InitializeComponent();
            }
    
            private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
            {
                this.img.Source = OKImage;
            }
        }

    Indeed I need to file a bug report to Microsoft.


    Ignorance is blissful


    • Edited by Neo the 1 Tuesday, September 10, 2019 3:20 PM
    Tuesday, September 10, 2019 3:19 PM
  • Hi,

    I still could not get this error message in the Xaml designer. I created a new sample with your code. And it looks like this in xaml:

    And in xaml code page:

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 11, 2019 12:50 AM
    Moderator
  • Sorry, by reliable I did not mean 100% success. Try close MainPage.xaml and reopen.

    Further investigation shows that the exception is caused by BitmapImage variable. If I changed it to a static property (using => shorthand) then the exception is gone.


    Ignorance is blissful




    • Edited by Neo the 1 Wednesday, September 11, 2019 8:17 PM
    Wednesday, September 11, 2019 9:29 AM
  • Hi,

    After trying to many times for closing and reopen the xaml, I still couldn't reproduce this.

    It looks correct like this:

     Another thing I'm sorry to say is that even I could reproduce this, there is nothing I can do with the XAML designer. I'd suggest you to report a problem for the XAML designer. Click the Help button on the Top bar and Select Send Feedback and then choose Report a Problem

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, September 12, 2019 12:54 AM
    Moderator