mrbrl / PCLAppConfig

Xamarin.Forms PCL App.Config Manager
Apache License 2.0
21 stars 10 forks source link

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

Open Juansero29 opened 5 years ago

Juansero29 commented 5 years ago

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!

soroshsabz commented 4 years ago

ITNOA

@mrbrl did you can take some workaround about this problem?

thanks a lot :)

soroshsabz commented 2 years ago

@Juansero29 Did you try new version of this package? Did you problem still exist?