locked
Errors trying to precompile and publish ASP.Net MVC 5 project RRS feed

  • Question

  • User1197721336 posted

    I have my project running on localhost and production, however because of the slow first access of each view, I'm trying to publish it precompiled (Precompile during publishing > (Disabled) Allow precompiled site to be updatable).

    I saw that the errors are all related to my ViewModel classes (which I repeat, they work correctly on localhost and on production without precompiling).

    The type or namespace name 'ChangePasswordViewModel' does not exist in the namespace 'ProjectName.Models' (are you missing an assembly reference?)

    I already deleted the entire content of the Temporary ASP.NET Files\root\, bin and obj folders.

    Even publishing to local path gives the same error.

    Tuesday, November 29, 2016 6:12 PM

Answers

  • User1197721336 posted

    For documentation purposes I'm posting the solution to my problem.

    The ASP.Net MVC project template creates authentication classes on project root, then I moved these classes to an area and replaced the namespace.

    Then the problem was that some Views didn't get the new namespace. After fixing the `@model` references, the publish feature worked.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 5, 2016 4:21 PM

All replies

  • User-2057865890 posted

    Hi Julianonunes,

    The error can result from different actions.

    Reference an Assembly That Is Not Included in the Client Profile
    Reference a Project or Assembly That Targets a Different Version of the .NET Framework
    Re-Target a Project to a Different Version of the .NET Framework
    Re-Target a Project to a Different Version of the .NET Framework and References Do Not Resolve

    Compiler Error CS0234

    https://msdn.microsoft.com/en-us/library/0e92xd7b.aspx

    Troubleshooting .NET Framework Targeting Errors

    https://msdn.microsoft.com/en-us/library/cc668079(v=vs.100).aspx 

    Best Regards, 

    Chris

    Wednesday, November 30, 2016 9:56 AM
  • User1197721336 posted

    Hi Chris,

    It's a single project solution and I'm it is not set for Client Profile. All references has been added via Nuget Packages and the app is working on development and production environments. The only thing that is not working is the precompile option from the publish feature.

    Wednesday, November 30, 2016 10:17 AM
  • User-2057865890 posted

    Hi Julianonunes,

    Rebuild your solution. Then look at your error list, double click on the error in the Error list.

    There has to be a namespace called ProjectName.Models that has a class called ChangePasswordViewModel that is public.

    namespace ProjectName.Models
    {
        public class ChangePasswordViewModel
        {
        }
    }

    Best Regards,

    Chris

    Friday, December 2, 2016 8:59 AM
  • User1197721336 posted

    There are no compilation errors. The classes from my ViewModel folder are all correctly used if not precompiled.

    Friday, December 2, 2016 9:21 AM
  • User1197721336 posted

    For documentation purposes I'm posting the solution to my problem.

    The ASP.Net MVC project template creates authentication classes on project root, then I moved these classes to an area and replaced the namespace.

    Then the problem was that some Views didn't get the new namespace. After fixing the `@model` references, the publish feature worked.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 5, 2016 4:21 PM