Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • William Even 23 posts 153 karma points
    Nov 26, 2019 @ 20:44
    William Even
    0

    Visual Studio 2019 Frustrations

    I am attempting to work with templates in Visual Studio 2019 after creation in the Umbraco Back Office (using Umbraco V.8.3).

    Whenever I create a new document type and attempto open the associated template/view in Visual Studio, I instantly receive an error stating that the

    type or namespace name 'HomePage' does not exist in the namespace 'Umbraco.Web.PublishedModels'.

    I thought I was able to use VS, but it appears I cannot (?).

    Am I missing something?

    Thank you, Bill Even CTG

  • Amir Khan 1282 posts 2739 karma points
    Nov 26, 2019 @ 21:36
    Amir Khan
    100

    Might need to switch your Models Builder Mode: https://our.umbraco.com/documentation/reference/templating/modelsbuilder/

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Nov 26, 2019 @ 21:42
    Nik
    0

    Hey Bill,

    The error you are seeing is misleading I believe. I'm making an assumption that you are using a default installation of Umbraco here.

    By default, Umbraco runs with models in Pure Live mode. What this means is that the class models don't really exist until runtime. The templates that are created by Umbraco have code to access the model, however because they don't quite exist yet visual studio, in particular, the intelisese and the compiler don't know about the classes. This is why "errors" are shown. The reason they are false errors is because the views aren't evaluated untill runtime and by this point the pure live models have been generated and so no error actually exists.

    If you want to have intelisese pick up the models you'll need to change the models builder mode.

    Nik

  • William Even 23 posts 153 karma points
    Dec 04, 2019 @ 14:59
    William Even
    0

    Amir and Nik both had the right idea, but Nik provided a little more detail. I marked you both as solution givers.

    Thank you.

    Bill

  • Amir Khan 1282 posts 2739 karma points
    Dec 04, 2019 @ 15:31
    Amir Khan
    0

    Thanks Bill, glad you sorted it out. Amazing how those types of things can be so frustrating the first time you encounter them.

Please Sign in or register to post replies

Write your reply to:

Draft