Copied to clipboard

Flag this post as spam?

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


  • Edgar Rasquin 326 posts 925 karma points
    Mar 09, 2023 @ 16:47
    Edgar Rasquin
    0

    Compilation error on new Document Type in LiveAppData mode

    Hi,

    I have a strange problem that I have been struggling with for a few days now. In my existing website V8, which I developed in Visual Studio and then published, I created in live environment a Document Type with Template.

    In the web.config I have the following settings as usual:

    <add key="Umbraco.ModelsBuilder.Enable" value="true" />
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="LiveAppData" />
    

    For testing purposes I create only one property. In the permissions I set Allow as root.

    As expected, the .generated.cs is in the directory under App_Data > Models. The .cshtml is in the Views directory.

    Under content I now create a page. When I call up this page, I get the following error:

    Compilation Error
    Description: An error occurred during the compilation of a resource 
    required to service this request. Please review the following specific 
    error details and modify your source code appropriately.
    
    Compiler Error Message: CS0234: The type or namespace name 
    'ConfirmationPage' does not exist in the namespace 
    'Umbraco.Web.PublishedModels' (are you missing an assembly 
    reference?)
    
    Source Error:
    
    
    Line 40:     
    Line 41:     
    Line 42:     public class _Page_Views_ConfirmationPage_cshtml : 
     Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.ConfirmationPage> 
    {
    Line 43:         
    Line 44: #line hidden
    
    Source File:      C:\Inetpub\vhosts\myDomain.com\tmp\root\315944a4\9c483555\App_Web_confirmationpage.cshtml.65a2d1ee.zwf0dxa1.0.cs    Line: 42required to service this request. Please review the following specific error details and modify your source code appropriately.
    

    enter image description here

    Any Ideas?

  • Daniël Knippers 153 posts 1116 karma points MVP 2x c-trib
    Mar 10, 2023 @ 09:22
    Daniël Knippers
    0

    Do you see a ConfirmationPage.generated.cs in App_Data > Models? If it's there, is the namespace actually Umbraco.Web.PublishedModels or did you configure a custom modelsbuilder namespace?

  • Edgar Rasquin 326 posts 925 karma points
    Mar 10, 2023 @ 10:20
    Edgar Rasquin
    0

    It is there and the Namespace is Umbraco.Web.PublishedModels

        using System;
        using System.Collections.Generic;
        using System.Linq.Expressions;
        using System.Web;
        using Umbraco.Core.Models;
        using Umbraco.Core.Models.PublishedContent;
        using Umbraco.Web;
        using Umbraco.ModelsBuilder.Embedded;
    
        namespace Umbraco.Web.PublishedModels
        {
            /// <summary>Confirmation Page</summary>
            [PublishedModel("confirmationPage")]
            public partial class ConfirmationPage : PublishedContentModel
            {
                // helpers
        #pragma warning disable 0109 // new is redundant
                [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "8.18.5")]
                public new const string ModelTypeAlias = "confirmationPage";
                [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "8.18.5")]
                public new const PublishedItemType ModelItemType = PublishedItemType.Content;
                [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "8.18.5")]
                public new static IPublishedContentType GetModelContentType()
                    => PublishedModelUtility.GetModelContentType(ModelItemType, ModelTypeAlias);
                [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "8.18.5")]
                public static IPublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<ConfirmationPage, TValue>> selector)
                    => PublishedModelUtility.GetModelPropertyType(GetModelContentType(), selector);
        #pragma warning restore 0109
    
                // ctor
                public ConfirmationPage(IPublishedContent content)
                    : base(content)
                { }
    
                // properties
    
                ///<summary>
                /// Content
                ///</summary>
                [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "8.18.5")]
                [ImplementPropertyType("content")]
                public virtual global::System.Web.IHtmlString Content => this.Value<global::System.Web.IHtmlString>("content");
            }
        }
    
  • Daniël Knippers 153 posts 1116 karma points MVP 2x c-trib
    Mar 10, 2023 @ 10:25
    Daniël Knippers
    0

    You have included the App_Data\Models folder in your solution? That is, the C# files in there are being compiled? You can also verify it by right-clicking ConfirmationPage.generated.cs in Visual Studio and select Properties.

    It should say Build Action: Compile, do you also see that?

    enter image description here

  • Edgar Rasquin 326 posts 925 karma points
    Mar 10, 2023 @ 10:44
    Edgar Rasquin
    0

    I am sorry if I have expressed myself in a misleading way. In my local development environment I can call up the page without errors.

    The error occurs when I try to create a new document type in the Productive Online instance. (This has always worked without problems in the past).

    After I download the database and start the project in VS, run the model builder, include the generated models and views in the project, the page works.

    My problem then is that even if I load the dlls, views and generated models back onto the server, online the problem persists?

    Am I doing something wrong?

    Thank you

  • Daniël Knippers 153 posts 1116 karma points MVP 2x c-trib
    Mar 10, 2023 @ 10:52
    Daniël Knippers
    100

    The compiled ConfirmationPage.generated.cs should be inside <Your_Project>.dll, and you have copied that one to the Production environment too after compiling it locally?

  • Edgar Rasquin 326 posts 925 karma points
    Mar 10, 2023 @ 11:06
    Edgar Rasquin
    0

    OK, that was the crucial clue. Now the page works.

    Thanks for the help Daniël!

    Does this mean that I can no longer create new document types in the backend in the productive environment? Then, every time I create new document types, I would have to do this locally at the same time so that the generated models are integrated into the main dll?

    Has anything changed recently? As far as I remember, it used to be possible to make these changes exclusively online, on the fly, so to speak, or am I mistaken?

  • Daniël Knippers 153 posts 1116 karma points MVP 2x c-trib
    Mar 10, 2023 @ 12:35
    Daniël Knippers
    1

    Glad that worked.

    If you want it to work without updating the DLL you probably have to set ModelsMode to PureLive, maybe that setting was changed recently in your site? That compiles the models on the fly so should work but then you cannot use the model classes from your own code (then they are only available in Views as far as I know).

    We also use AppData at my company so I have no experience using PureLive in production but that should work in theory.

Please Sign in or register to post replies

Write your reply to:

Draft