Copied to clipboard

Flag this post as spam?

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


  • SteveMid 25 posts 127 karma points
    Mar 22, 2022 @ 12:48
    SteveMid
    0

    ModelsMode set to 'InMemoryAuto' causing error

    I attempted to follow a few guides to allow me to send a simple contact form, but failed to get it working (my ASP.NET / MVC is quite basic - I'm mostly just trying to use Umbraco as a CMS without much custom work but had to go out of my comfort zone to try and get a form working), so for now, I may have to use Umbraco Forms.

    Anyway... during the tutorials, I made a change to the appsettings.json file to change the ModelsMode to 'SourceCodeAuto' like so:

       "ModelsBuilder": {
          "ModelsMode": "SourceCodeAuto"
        }
    

    This has resulted in me having to stop Debugging mode and rebuild the project every time I make a change such as adding a new Document Type (from within Umbraco in-browser), so I decided to change it back to the default 'InMemoryAuto' setting, but when I do that, I receive 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. Generated Code
    
    The type 'HomePage' exists in both 'ModelsGeneratedAssembly, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null' and 'MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
    +
        public class Views_HomePage : Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.HomePage>
    

    I would appreciate any suggestions how to get things back to how they were before I started meddling! Thanks.

  • Will Price 12 posts 94 karma points
    Oct 18, 2022 @ 23:04
    Will Price
    0

    I know this is old, but don't suppose you or anyone else worked out a solution to this Steve?

    I'm having the same issue with Umbraco 10.2.1 and Visual Studio 2022

    I did have (default) inMemoryAuto, changed to SourceCodeAuto when trying to fix another issue, and now can't go back to InMemoryAuto. After setting appsettings to InMemoryAuto, building, and running the site, I get the following error:

    The type '[myTypeName]' exists in both 'ModelsGeneratedAssembly, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null' and '[myProjectName], Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'

  • Will Price 12 posts 94 karma points
    Oct 18, 2022 @ 23:43
    Will Price
    0

    OK, I finally worked it out, and as usual it is obvious. The old models were still there.

    Delete the /umbraco/models folder.

    I also deleted all files in obj/debug/net6.0 and bin/Debug/net6.0 to be sure before I rebuilt and ran the solution

  • Rob Watkins 369 posts 701 karma points
    Aug 16, 2023 @ 10:43
    Rob Watkins
    0

    I got this error after renaming the site assembly; it was because in _ViewImports.cshtml the old assembly name was still being used.

Please Sign in or register to post replies

Write your reply to:

Draft