Skip to content

The Xamarin.Forms Previewer doesn't work since I use PCLAppConfig  #22

Description

@Juansero29

When trying to render any page (even a newly created page with only a label inside) and using the PCLAppConfig NuGet, the Xamarin.Forms Previewer fails to render the controls since it tries to search for the App.config file and it doesn't find it.

As seen in the image below, I get a System.IO.FileNotFoundException when opening the Xamarin.Forms Previewer. This has the same behavior on any page and seems to come from the PCLAppConfig.FileSystemStream.AndroidAppConfigPathExtractor.get_Path() method called by PCLAppConfig.FileSystemStream.PortableStream.CreateAppConfigStream() method.

xamarin previewer pclconfig

I do have the App.config file in both my Android and iOS projects but still it refuses to render my pages and controls.

I think the problem can be fixed by adding a design mode condition in the PCLAppConfig.FileSystemStream.PortableStream.CreateAppConfigStream() method so that it returns if we're in design mode and doesn't try to search for the file . You can use DesignMode.IsDesignModeEnable and use it as shown on this XAML Previewer page to make the Xamarin.Forms Previewer work again.

As a hint, you can open any XAML file in the Xamarin.Forms Previewer by right clicking the file, choose "Open with..." and then choosing "Xamarin.Forms Previewer". You can also set it as default if wanted to make some tests.

A fix would be really appreciated since me and my team would want to test the new capabilities of VS2019 to render pages and controls via the previewer. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions