3
votes

Is it possible to have all pages in a different project from where the app.xaml/cs is in?

I tested this by creating a new "Class Library (Universal Windows)" or "Windows Runtime Component" project, then I created the new pages in those projects.

After I add this project as a reference to the main UWP app and call the page(s) in the "rootFrame.Navigate(typeof(MainShellView), e.Arguments)" I get the exception

system.accessviolationexception attempted to read or write protected memory

Is it possible to have the pages, controls in different projects than the UWP main project and use them as references?

1
It works for me. Here is the project I tested with: 1drv.ms/u/s!AovTwKUMywTNsOtjFDhndJwWePnTkQ Can you share your repro that crashes? - Stefan Wick MSFT
I tried yours, I deleted the main page from the UWP project and then did a rebuild and deploy and stopped working throwing the error that I described, can you test it again? - J_PT
I see. There seems to be a hard coded reference somewhere in the project system. I'll log a bug on that. For now, why not just leave an empty MainPage.xaml in the project? - Stefan Wick MSFT
thanks, yep it seems the temp solution for that, thank you - J_PT

1 Answers

4
votes

You will need to keep an empty/dummy MainPage.xaml page in the main project as there is a hard-coded reference to it in the project system. With that in place you can load all your pages (incl. the initial start page) from other projects that you are referencing in the solution.

I will log a bug on the hard-coded dependency on the existence of "MainPage.xaml". Thanks for reporting!