Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to Resolve Exception: Cannot create an instance of "WindowsPage".

ChrisNavarreChrisNavarre USMember
edited May 2016 in Xamarin.Forms

Hey everyone,

Brand new to Xamarin forms here and trying to get started in cross platform app development using the package. However right out of the gate I seem to be running into an issue that has been asked a few times elsewhere but I haven't really seen an actual response on. Currently I'm trying to work on the UWP / Universal Windows / Windows 10 User Interface in a Portable Forms / PCL setup.

It's the Cannot create an instance of WindowsPage error message in the Microsoft Visual Studio 2015 Xaml designer. I'm following the guide at https://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/ so I added the line for "xmlns:forms="using:Xamarin.Forms.Platform.UWP" the xaml file before changing the page tag from Page to forms:WindowsPage thus referencing the xamarin forms package. I did update all the NuGet packages to the latest version. Xamarin forms is something like 2.2 at the moment.

I initially installed the defaults for the VS2015 Xamarin package and I just tried modifying that installation with every extra component included so I don't think I'm missing anything there. I believe Xamarin is installed properly since it shows up in the Help -> Xamarin menu and I can choose new solutions out of the Xamarin forms package but I'm not sure what could be causing the issue.

Here's the XAML code

<forms:WindowsPage
    x:Class="SoloPathfinderPCL.UWP.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:forms="using:Xamarin.Forms.Platform.UWP"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SoloPathfinderPCL.UWP"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

</forms:WindowsPage>

Here's my Stack Trace for Exception: Cannot create an instance of "WindowsPage".
at Microsoft.VisualStudio.DesignTools.Platform.InstanceBuilders.InstanceBuilderOperations.InstantiateType(Type type, Boolean supportInternal) at Microsoft.VisualStudio.DesignTools.Platform.InstanceBuilders.ClrObjectInstanceBuilder.InstantiateTargetType(IInstanceBuilderContext context, ViewNode viewNode) at Microsoft.VisualStudio.DesignTools.Platform.InstanceBuilders.ClrObjectInstanceBuilder.Instantiate(IInstanceBuilderContext context, ViewNode viewNode) at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.InstanceBuilders.FrameworkElementInstanceBuilder.Instantiate(IInstanceBuilderContext context, ViewNode viewNode) at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.InstanceBuilders.UserControlInstanceBuilder.Instantiate(IInstanceBuilderContext context, ViewNode viewNode) at Microsoft.VisualStudio.DesignTools.Platform.InstanceBuilders.ViewNodeManager.CreateInstance(IInstanceBuilder builder, ViewNode viewNode)

Hope someone can point me and everyone else having this issue in the right direction. Thanks.

Posts

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @ChrisNavarre - first step and I just have to ask, did you restart Visual Studio after you installed the latest Nuget packages? It generally needs a restart.

    Also are you actually getting a build/compile error or is this just an intellisense error?

  • ChrisNavarreChrisNavarre USMember

    Yes I restart the studio and computer multiple times.

    It's an intellisense error. The app compiles fine but the designer won't load with form:WindowsForm being used.

  • ChrisNavarreChrisNavarre USMember

    Tried reinstalling Visual Studio still no help.

    Here's a screenshot.

  • DonaldGirardinDonaldGirardin CAMember

    Same problem for me; Do you have a solution?

  • ChrisNavarreChrisNavarre USMember
    edited May 2016

    I did some more digging around and I ran across this thread
    https://forums.xamarin.com/discussion/63707/vs-2015-pro-cannot-create-an-instance-of-windowspage-in-design-view

    Apparently there is no functional designer display for the Windows Apps (UWP) side of things when built with Xamarin Forms? They say the error is to be expected. Pretty frustrating to get something so cryptic out of the gate honestly.

    There's this project for taking Xamarin XAML and being able to preview it http://gorillaplayer.com/
    Don't bother there's no functional download at the moment. Looks like we're stuck building and compiling with in order to check our UIs while using Xamarin Forms.

  • I getting these Error

  • Tamer.AhmedTamer.Ahmed USMember ✭✭

    Same here with the latest version

  • DavidAllenDavidAllen USDeveloper Group Leader ✭✭✭

    Yup, this is still an issue. It would be great to have a functioning design view previewer that could support Xamarin.Forms, however even the ability to disable design view in VS to prevent the "red squiggles" would be really useful. I have submitted a bug report to the Visual Studio team, but I doubt we will get a resolution for VS 2015. I haven't migrated to VS2017, lets hope they fix this in that.

  • MarcBrunoMarcBruno USMember
    edited January 2017

    After numerous days of troubleshooting, installs, updates, configurations and trials++ I did manage to get a preview of xaml designer for windows files (not iOS nor Android) {Win10-14393/VS2015-3/jdk1.7/XamarinSDK25/NuGetForms2.3}. It was unfortunately short lived as it got disrupted with other attempts to make other things work and I no longer have the pleasure to try it out.

    The beauty of VS since the early 90's was that it was a great code generator by dragging and dropping controls visually and made it intuitive. Things seem to be going backwards ever since with so many OS available and other complications. Regardless, the promises of easily building cross-platform apps in one central repository with xamarin.forms is easier said than done. Very inefficient text editor if intellisense doesn't excel and the visual designer components of drag/drop, adjust and modify the properties sheet isn't available.

    I truly hope there shall be an interim solution very soon as it would cut down the work substantially. I guess it be suitable for those lucky employees ;)

  • hz10hz10 USMember ✭✭

    Same problem here.
    I am so glad to find this thread confirming the issue by design. I am evaluating the options of migrating an app to UWP. This helps me make up my mind quickly.

  • JohnSheehan.3374JohnSheehan.3374 USMember ✭✭

    Any resolution ? This is a deal breaker ..

  • TekwareSoftwareTekwareSoftware USMember

    This is really frustrating that the wrong opening tag is generated but I found a very easy fix for this; Just shorten the opening code tag from forms:WindowsPage to Page: The closing tag will edit itself automatically to /Page and fix itself. This is a really easy fix and will instantly get rid of the error.

  • dinobdinob USUniversity ✭✭✭

    Same problem and very frustrating. Visual Studio 2015

Sign In or Register to comment.