preview of UserControls not working in a class library | The element "foo" could not be displayed due to missing assemblies

Dominic Jonas 1 Reputation point
2020-06-08T06:24:12.313+00:00

I have a UWP solution with three projects:

App1 ,ClassLibrary1 and ClassLibrary2

In the App1 and ClassLibraries are each with a custom UserControl. While it's possible to get a preview (of the UserControls) in the designer of the the App1.Page1, the preview in ClassLibrary1.Page1 is not working.

I always get the following error message: The element "foo" could not be displayed due to missing assemblies

JuInWnu.png

iEA3yBQ.png

ErrorMessage:

XlFF4rb.png

Solution file:

files.dominic-jonas.de/stackoverflow/App1.zip

The following steps I tried so far (without success):

clean solution
rebuild project
deleted cache
dotnet clean
dotnet restore
restarted windows
updated VisualStudio (v16.6.0) and tried v16.7.0 preview 1

Anyone know how I can get the preview fixed?

Thanks!

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Richard Zhang-MSFT 6,936 Reputation points
    2020-06-08T12:50:14.94+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I downloaded the project you provided, after cleaning the solution and rebuilding, I was able to see two rectangles, one red and one yellow in the Design view of BlankPage1, here are my steps:

    1. Download and unzip the solution
    2. Delete the .vs folder
    3. Open solution, and check the x64 platform.
    4. Clean Solution, Rebuild App1 project
    5. Select the BlankPage1.xaml, switch to Design window

    What may be different from you is that the Visual Studio I use is v16.6.1.

    As a comparison reference, you can download your own code compression package and follow the steps I provided to see if there are different results.

    Thanks.

    1 person found this answer helpful.
    0 comments No comments

  2. Dominic Jonas 1 Reputation point
    2020-06-23T06:40:01.87+00:00

    Hello Richard,

    I am very grateful to you for your proposed solution! In the minimal sample project I uploaded, this is the solution!
    However, this solution does not work in my "main project". The following project types are included. Maybe that's why it doesn't work there?

    • installer
      • HtSuite.Server.Setup WIX 3 Project
      • HtSuite.Wpf.Leitstand.Setup WIX 3 Project
      • HtSuite.Wpf.Workstation.Setup WIX 3 Project
    • server
      • HtSuite.Server netcoreapp3.1
      • HtSuite.Server.Common netcoreapp3.1
    • src
      • HtSuite.Common netstandard2.0;net461
      • HtSuite.ErrorCodes netstandard2.0
      • HtSuite.GraphQL.Client netstandard2.0;net461
      • HtSuite.GraphQL.Server netcoreapp3.1
      • HtSuite.Local netstandard2.0
      • HtSuite.NLog netstandard2.0
    • tests
      • HtSuite.TestHelpers netcoreapp3.1
      • HtSuite.UnitTests netcoreapp3.1
    • ui
      • HtPlcFramework net461
      • HtSuite.UWP UWP
      • HtSuite.UWP.Leitstand UWP
      • HtSuite.WPF.Common net461
      • HtSuite.WPF.Leitstand net461
      • HtSuite.WPF.Workstation net461

    Could it be that there is an internal conflict due to the many different project types?

    Best Regards
    Dominic Jonas

    Ug6mNAL.png

    rNbTy8j.png

    0 comments No comments

  3. Dominic Jonas 1 Reputation point
    2020-06-24T09:16:28.483+00:00

    I made a new solution HtSuite.UWP with only the following projects and removed the net461 targetFrameworks:

    • src
      • HtSuite.Common netstandard2.0
      • HtSuite.ErrorCodes netstandard2.0
      • HtSuite.GraphQL.Client netstandard2.0
      • HtSuite.GraphQL.Server netcoreapp3.1
      • HtSuite.Local netstandard2.0
      • HtSuite.NLog netstandard2.0
    • ui
      • HtSuite.UWP UWP
      • HtSuite.UWP.Leitstand UWP

    I tried x86 and x64 without success. Since you are an official microsoft employee, I would make my project available to you. In case you want to deal with it.

    Best Regards
    Dominic

    6QttqzV.png
    OJ37KJk.png