Copied to clipboard

Flag this post as spam?

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


  • Joseph May 11 posts 102 karma points
    Jan 28, 2020 @ 21:12
    Joseph May
    0

    Question about generated models

    Hello,

    I am working with my team on the trial version of Umbraco Cloud. We're using the Igloo theme to quickly build out a sample site.

    We are currently seeing the following error after an update to Umbraco.Deploy was pushed to fix an issue. We have no custom C# code of our own though.

    enter image description here

    It seems like deploying the changes to Umbraco.Deploy kicked off a new model generation and exposed an issue. I get this locally as well. Has anyone seen this type of error? I'm not really sure what to do about it.

    Thanks, Joe

  • Nik 1300 posts 5503 karma points MVP 3x c-trib
    Jan 28, 2020 @ 22:12
    Nik
    0

    Hi Joseph,

    Looking at the error message it appears your models have been generated twice in 2 different forms.

    On your local instance, have a look an see if there following files exist:

    1. Umbraco.Web.PublishedModels located in your bin directory
    2. AllWeball.generated.cs in your app_data folder (I can't remember exactly where in the folder).

    If they both exist delete them both and restart the website. The easiest way to trigger this is to modify the web.config and add a space at the end of the file and save it.

    I think that should fix the issue, in that when the site restarts the models should be re-generated cleanly.

    If it works locally, you should be able to repeat the process on your Umbraco Cloud instance.

    Nik

  • Joseph May 11 posts 102 karma points
    Jan 29, 2020 @ 15:32
    Joseph May
    0

    Thanks for this information!

    We did have an Umbraco.Web.PublishedModels.dll in the bin folder in addition to the app_data\models\ generated files.

    It sounds like since we are in PureLive mode, the Umbraco.Web.PublishedModels.dll in the bin folder was conflicting with the one generated in memory. Does it sound like I'm understanding that correctly?

    I cleaned out the models folder and removed the dll from the bin folder, then re-generated (a few different ways, to be sure: recycled app pool, edited web.config with a space at the end, and saved an existing document type). The files in the models folder were re-generated, but now we get a new error:

    enter image description here

    Now it's saying we need to add a reference to Umbraco.Web.PublishedModels, but I'm not sure why we'd be getting that when this all worked before and we haven't edited anything code-wise out of the box.

    The views web.config contains

    add namespace="Umbraco.Web.PublishedModels"

    I've also tried adding a using statement in the cshtml for Umbaco.Web.PublishedModels, but that didn't change anything.

  • Nik 1300 posts 5503 karma points MVP 3x c-trib
    Jan 29, 2020 @ 16:31
    Nik
    0

    Hi Joseph,

    The way in which you are calling General seems a bit odd to me to be honest.

    I've not seen a model with a .Settings() method on it before. Do you have code somewhere that is attempting to extend you general models?

    Thanks

    Nik

  • Joseph May 11 posts 102 karma points
    Jan 29, 2020 @ 16:50
    Joseph May
    0

    Settings comes from a template:

    enter image description here

    I'm actually not sure why it's being called as a method, though treating it as a property throws an error saying it needs to be invoked as a method. I thought maybe it was an idiosyncrasy of how Umbraco exposes content to the Razor views.

  • Nik 1300 posts 5503 karma points MVP 3x c-trib
    Jan 29, 2020 @ 16:53
    Nik
    0

    In your Master.cshtml file, what does the @Inherits statement look like? And can you share what your content tree looks like?

  • Joseph May 11 posts 102 karma points
    Jan 29, 2020 @ 17:39
    Joseph May
    0

    Here's the content tree:

    enter image description here

    And here's the top of the master.cshtml file.

    enter image description here

  • Nik 1300 posts 5503 karma points MVP 3x c-trib
    Jan 29, 2020 @ 17:45
    Nik
    100

    Hi Joseph,

    Okay so I'm going to make some assumptions here now.

    I have a theory that Settings() is a custom extension method that someone has made for you. Most likely it exists in the namespace Igloo.Extensions and is an extension method for IPublishedContent. The reason for making this assumption is, if this was not the case, then you would be getting a very different error message.

    Now, the question is where is the source code for this extension method? My guess would be that this extension method is in an external library that your site is using and that library expects your site to be using DLL mode and not pure live mode. As a result when we did the clean up of the models builder conflict earlier we exposed a new issue.

    It would be worth doing the following:

    1. Change Models Builder mode to DLL instead of PureLive.
    2. Delete the PureLive models builder file that was previously generated
    3. Rebuild the Models
    4. Restart the website
    5. Test to see if this resolves the issue.

    If it does fix the issue, the next thing you'll probably want to do is find the sourcecode for Igloo.Extensions (I'm affraid without seeing the site code I can't advise any pointers on that though).

    Thanks

    Nik

  • Joseph May 11 posts 102 karma points
    Jan 29, 2020 @ 17:56
    Joseph May
    1

    You got it. There was a theme installed called Igloo. I didn't realize it depended on the models being done a certain way. So what I did was:

    1. Remove files from app_data\models
    2. Update Umbraco.ModelsBuilder.ModelsMode in web.config to Dll
    3. In the backoffice under "Models Builder", clicked the "Generate models" button. This restarts the site and compiles an Umbraco.Web.PublishedModels.dll file in the bin folder.

    The site now works as expected. Thank you so much for your help with this!

    Joe

  • Nik 1300 posts 5503 karma points MVP 3x c-trib
    Jan 29, 2020 @ 17:57
    Nik
    0

    No problem, happy we got it sorted for you 👍

Please Sign in or register to post replies

Write your reply to:

Draft