Copied to clipboard

Flag this post as spam?

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


  • Thor Muto Asmund 3 posts 75 karma points
    Feb 10, 2016 @ 08:09
    Thor Muto Asmund
    1

    Autogenerated templates do not compile

    Autogenerated doctype templates do not compile in the visual studio editor. I created the templates in Umbraco version 7.4.0-RC1, and the generated cshtml looks like this:

    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Article>
    @{
        Layout = null;
    }
    

    The error is

    Severity Code Description Project File Line Error CS0234 The type or namespace name 'Article' does not exist in the namespace 'Umbraco.Web.PublishedContentModels' (are you missing an assembly reference?)

    It seems the class ContentModels.Article cannot be found.

    How do I get this to compile?

  • Thor Muto Asmund 3 posts 75 karma points
    Feb 10, 2016 @ 13:01
    Thor Muto Asmund
    1

    Found the solution. It should be enough to edit the web.config like this:

    <add key="Umbraco.ModelsBuilder.ModelsMode" value="Dll" /> 
    

    Then rebuild the models on the datatypes in the Umbraco backend.

  • Craig100 1059 posts 2321 karma points c-trib
    Feb 15, 2016 @ 00:11
    Craig100
    2

    Just found this problem on my first template. Changed

    <add key="Umbraco.ModelsBuilder.ModelsMode" value="PureLive" />
    

    to

    <add key="Umbraco.ModelsBuilder.ModelsMode" value="Dll" />
    

    Then rebuilt models in the Developer Section ModelBuilder tab. Nothing changes. The back end says "Models out of date"

    Template still shows an error in VS2015.

    Craig

  • Stephen 767 posts 2265 karma points c-trib
    Feb 15, 2016 @ 08:28
    Stephen
    1

    Quick answer: in PureLive the models exist only in memory at runtime, so Visual Studio does not know about them and reports errors. If you run the template, it should actually work.

    If you want Visual Studio to know about your models, they do need to exist in a proper DLL so the correct solution is indeed to go for value="Dll" and generate the DLL.

    If everything is properly configured in web.config then VS should find the generated DLL in the ~/bin directory, and be happy with your models.

    Currently preparing a blog post on that topic w/more details.

  • Stephen 767 posts 2265 karma points c-trib
    Mar 06, 2016 @ 10:29
  • David Zweben 225 posts 662 karma points
    Jul 05, 2016 @ 18:09
    David Zweben
    1

    I had an Umbraco 7.4 project which was installed and run from outside of Visual Studio, and which I wanted to run from within Visual Studio. I got an error message (below), and a search for it brought me here. Below are the exact steps to get it working.

    Error message Visual Studio gave me:

    the type or namespace "[something]" does not exist in the namespace umbraco.web.publishedcontentmodels
    

    For me, the [something] corresponded to the name of a document type. The solution below assumes this is the case.

    Solution:

    1) Go into Web.config, and change the line

    <add key="Umbraco.ModelsBuilder.ModelsMode" value="PureLive" />

    to

    <add key="Umbraco.ModelsBuilder.ModelsMode" value="Dll" />

    2) Run the website again from outside Visual Studio

    3) Go into Settings > Document Types > [Something] document type

    4) On the Save button, you should now see a button to open a menu (if not, poke web.config and reload). Click "save and generate models".

    5) Repeat this for each instance of the error message.

    6) Run the project from Visual Studio.

    This got it working for me. By my understanding, you will now have to "Save and generate models" each time changes are made, to maintain Visual Studio compatibility.

  • Silvan Egger 28 posts 200 karma points
    Jul 13, 2016 @ 08:59
    Silvan Egger
    1

    Hey thanks for that!

    But i got a Problem.. When i click "Save and generate models" i get an error:

    Models generation has failed, see exception in U log

    What can I do?


    EDIT I changed the value from Dll to LiveDll. Now it works. In this mode it creates always all models for all Document Types.

    <add key="Umbraco.ModelsBuilder.ModelsMode" value="LiveDll" />
    

    Read more about the ModelsModes on this Link: https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki/Builder-Modes

  • Phong Nguyen Dinh 26 posts 197 karma points
    Oct 17, 2016 @ 06:49
    Phong Nguyen Dinh
    0

    I did exactly like you said but it wasn't working. In step 2, after changed the line

    <add key="Umbraco.ModelsBuilder.ModelsMode" value="PureLive" />
    

    to

    <add key="Umbraco.ModelsBuilder.ModelsMode" value="Dll" />
    

    I couldn't run the website again, The error was

    System.Configuration.ConfigurationErrorsException: ModelsMode "DLL" is not a valid mode. Note that modes are case-sensitive.

    What should i do?

    Phong

  • Rohan Pathak 5 posts 74 karma points
    Sep 15, 2017 @ 15:40
    Rohan Pathak
    0

    Thanks! This worked for me.

  • Craig100 1059 posts 2321 karma points c-trib
    Oct 17, 2016 @ 08:11
    Craig100
    2

    You probably did this anyway, but did you build the solution after you changed the value?

  • Nitin Anand 38 posts 169 karma points
    Jul 13, 2018 @ 08:44
    Nitin Anand
    1

    I get this error CS0426: The type name 'Web' does not exist in the type 'Umbraco.Web.PublishedContentModels.* any clue?

Please Sign in or register to post replies

Write your reply to:

Draft