Copied to clipboard

Flag this post as spam?

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


  • Yaco Zaragoza 88 posts 363 karma points
    Apr 19, 2023 @ 17:21
    Yaco Zaragoza
    0

    An error occurred during the compilation...

    I created a new Document Type called "News Page" and when I create a page called "Internal News" of type "News Page" I am getting the following error.

    An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.

    One or more compilation references may be missing. If you're seeing this in a published application, set 'CopyRefAssembliesToPublishDirectory' to true in your project file to ensure files in the refs directory are published.

    The type or namespace name 'NewsPage' does not exist in the namespace 'Umbraco.Cms.Web.Common.PublishedModels' (are you missing an assembly reference?) + public class Views_NewsPage : Umbraco.Cms.Web.Common.Views.UmbracoViewPage

    When I looked at my models I see I have a file called NewsPage.generated.cs

    Can anyone point me to what I am doing wrong?

    If I go to the Template and updated

    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.NewsPage>
    

    to

    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
    

    The page works... Can someone explain to me why?

  • Dennis 75 posts 398 karma points MVP 2x
    Apr 19, 2023 @ 18:53
    Dennis
    0

    Heyo!

    It appears that the model that you generated cannot be found.

    There are multiple possible causes for this:

    • Can you confirm that the namespace of your model matches the namespace that the error mentions?
    • You seem to be generating your models as C# source files. Can you confirm that these source code files are included in your project and have been compiled into the output of your application?
  • Yaco Zaragoza 88 posts 363 karma points
    Apr 19, 2023 @ 19:02
    Yaco Zaragoza
    0

    Hello Dennis,

    I see the models are created see image.

    enter image description here

    enter image description here

    This is the page that calls the Model

    enter image description here

    Any ideas?

  • Dennis 75 posts 398 karma points MVP 2x
    Apr 20, 2023 @ 06:39
    Dennis
    0

    Hey,

    Just to be sure: have you rebuilt and restarted your application after creating your document type and template and after generating your models?

    Kind regards, Dennis

  • Yaco Zaragoza 88 posts 363 karma points
    Apr 20, 2023 @ 13:53
    Yaco Zaragoza
    0

    Hello Dennis,

    Yes, rebuilt the models by going to Settings >> Settings >> Models Builder and clicking on Generate Models.

    After that I stopped VS and did a build (Build Solution) and when I run it again I still get the same error.

    Can we do a 5 min Google Meeting for you to help me out with this?

  • Yaco Zaragoza 88 posts 363 karma points
    Apr 20, 2023 @ 15:55
    Yaco Zaragoza
    0

    I am not sure what I did, but it is now working...

  • ewuski 99 posts 287 karma points
    Feb 26, 2024 @ 19:34
    ewuski
    0

    The error indicates that a model does not exist or is not referenced. For example in a Razor model cannot be found.

Please Sign in or register to post replies

Write your reply to:

Draft