locked
Web deploy calling aspnet_compiler.exe which throws error: The type or namespace name 'UmbracoViewPage' could not be found RRS feed

  • Question

  • User-1224781418 posted

    Hi All,

     I am using Visual Studio 2019 (16.6.5) for development of a application using  Umbraco 7.5.10 (with uCommerce) and my project works well on my Windows 10  Dev / VS machine.

     I have now also been able to deploy to a (Go Daddy) hosted web server and have managed to do that successfully using Visual Studio Web Deploy (Publish).

     Now I am trying to deploy in the much the same manner (using Visual Studio Web Deploy / Publish) but this time with the following options:

    • Precompile during publishing
    • DO NOT allow precompiled site to be updatable

    Using Precompile during publishing results in the build process calling aspnet_compiler.exe as follows:

    C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v / -p C:\Clancy\A_TeraTastic\Dev\TT15\TeraTastic\obj\TTRelease\AspnetCompileMerge\Source C:\Clancy\A_TeraTastic\Dev\TT15\TeraTastic\obj\TTRelease\AspnetCompileMerge\TempBuildDir

    This results in a large number of warnings I do not yet understand, and am not worrying about these right now such as the following:

    2>ASPNETCOMPILER(0,0): Warning CS1685: The predefined type 'System.Collections.Generic.IReadOnlyList' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll'

    2>ASPNETCOMPILER(0,0): Warning CS1685: The predefined type 'System.Collections.Generic.IReadOnlyCollection' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll'

    But the Error I AM worried about and need assistance with please is the following

    2>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b29e350b\ca96019b\App_Web_vivjsxxz.1.cs(25,0): Error CS0246: The type or namespace name 'UmbracoViewPage' could not be found (are you missing a using directive or an assembly reference?)

    From what I can tell UmbracoViewPage  == Umbraco.Web.Mvc.UmbracoViewPage  and that exists in the assembly “umbraco.dll” which exists in my bin folder as well as in the obj location used by aspnet_compiler.exe  at C:\Clancy\A_TeraTastic\Dev\TT15\TeraTastic\obj\TTRelease\AspnetCompileMerge\Source\bin .  So I do not understand the reason why “  'UmbracoViewPage' could not be found  ” ???

     Also, how can I debug this !!!!  It says the error exists in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b29e350b\ca96019b\App_Web_vivjsxxz.1.cs(25,0)  which means nothing to me, and does not exist after the build fails and I go to look at it.   How can I tell what line, in what file, in my source code is causing this error ??

     Any help would be appreciated.

     

    Thanks

     Terry Clancy

    ClanceZ

    Thursday, July 23, 2020 6:27 PM

Answers

  • User-1224781418 posted

    Thank you Sam,

     OK I have resolved this issue and I am embarrassed to say that the solution was fairly straight forward.

    • (1) Rather than try to navigate to the file in the location listed in ……….\Temporary ASP.NET Files\....... I double clicked on the error in the Error List pane in VS to see the offending file.
    • (2) That file was not an exact copy of my source, but did have a line added near the top with the complete path to the original source file.
    • (3) In the original source file I then had to resolve the errors (remove the red squiggly lines) which in my case meant adding a “Using” statement
    • (4) One thing to note is that many pages that which worked OK before I tried to “PreCompile" the site, cause errors when being compiled by aspnet_compiler.exe. It seems a lot stricter than the JIT approach ?

    Thanks again for your assistance.

     Terry Clancy

    ClanceZ

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 29, 2020 4:41 PM

All replies

  • User288213138 posted

    Hi terryclancy1,

    Error CS0246: The type or namespace name 'UmbracoViewPage' could not be found (are you missing a using directive or an assembly reference?)

    Can you tell me what method you used to install UmbracoViewPage?

    If you are using the zip file download, it could be that you bin folder was cleaned during a rebuild in Visual Studio, visual studio cleans the folder for files during rebuilds, and pulls all the referenced libaries in to the folder.

    One way to fix this is copying the bin folder to a lib folder and reference all the files using the project references.

    I would recommend using the NuGet package to install the UmbracoViewPage.

    Best regards,

    Sam

    Friday, July 24, 2020 3:36 AM
  • User-1224781418 posted

    Hi Sam,

    Thanks.   From what I can tell the full name for UmbracoViewPage is Umbraco.Web.Mvc.UmbracoViewPage  and that exists in the assembly “umbraco.dll” which exists in my bin folder as well as in the obj location used by aspnet_compiler.exe  at C:\Clancy\A_TeraTastic\Dev\TT15\TeraTastic\obj\TTRelease\AspnetCompileMerge\Source\bin . 

    When I navigate to umbraco.dll using the VS Object Browser and navigate to Umbraco.Web.Mvc.UmbracoViewPage it says:

    public abstract class UmbracoViewPage : Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Core.Models.IPublishedContent>
    Member of Umbraco.Web.Mvc

    My solution has a "Reference" to  “umbraco.dll”  to a location outside of bin  ( C:\Clancy\A_TeraTastic\Dev\TT15\TeraTastic\App_Data\NuGetBackup\20170306-223942\bin\umbraco.dll ) and so a fresh copy should be brought in after each Clean / Rebuild All.

    So I still do not understand the reason why “  'UmbracoViewPage' could not be found  ” ???

    Terry Clancy

    ClanceZ

    Friday, July 24, 2020 4:39 PM
  • User-1224781418 posted

    Also for reference, if I call the aspnet_compiler.exe from the command line with the debug options "-d" and "-errorstack" as follows:

    aspnet_compiler.exe -f -d -errorstack -v / -p C:\Clancy\A_TeraTastic\Dev\TT15\TeraTastic\obj\TTRelease\AspnetCompileMerge\Source C:\Clancy\A_TeraTastic\Dev\TT15\TeraTastic\obj\TTRelease\AspnetCompileMerge\TempBuildDir

    Then I get the following more detailed error message. However I still do not understand the reason why “  'UmbracoViewPage' could not be found  ” ???

    c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b29e350b\ca96019b\App_Web_nm3iq5p3.1.cs(26): error CS0246: The type or namespace name 'UmbracoViewPage' could not be found (are you missing a using directive or an assembly reference?)

    [HttpCompileException]: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b29e350b\ca96019b\App_Web_nm3iq5p3.1.cs(26): error CS0246: The type or namespace name 'UmbracoViewPage' could not be found (are you missing a using directive or an assembly reference?)
    at System.Web.Compilation.AssemblyBuilder.Compile()
    at System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilder(AssemblyBuilder builder)
    at System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilderParallel(ICollection assemblyBuilders)
    at System.Web.Compilation.WebDirectoryBatchCompiler.CompileNonDependentBuildProviders(ICollection buildProviders)
    at System.Web.Compilation.WebDirectoryBatchCompiler.Process()
    at System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors)
    at System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors)
    at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
    at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
    at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
    at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
    at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
    at System.Web.Compilation.BuildManager.PrecompileAppInternal(VirtualPath startingVirtualDir, IEnumerable`1 excludedVirtualPaths)
    at System.Web.Compilation.BuildManager.PrecompileApp(VirtualPath startingVirtualDir, IEnumerable`1 excludedVirtualPaths)
    at System.Web.Compilation.BuildManager.PrecompileApp(ClientBuildManagerCallback callback, IEnumerable`1 excludedVirtualPaths)
    at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback, List`1 excludedVirtualPaths)
    at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback, List`1 excludedVirtualPaths)
    at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback, Boolean forceCleanBuild)
    at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback)
    at System.Web.Compilation.Precompiler.Main(String[] args)

    Thanks

    Terry Clancy

    ClanceZ

    Friday, July 24, 2020 7:52 PM
  • User288213138 posted

    Hi terryclabcy1,

    From what I can tell the full name for UmbracoViewPage is Umbraco.Web.Mvc.UmbracoViewPage  and that exists in the assembly “umbraco.dll” which exists in my bin folder as well as in the obj location used by aspnet_compiler.exe  at C:\Clancy\A_TeraTastic\Dev\TT15\TeraTastic\obj\TTRelease\AspnetCompileMerge\Source\bin . 

    When I navigate to umbraco.dll using the VS Object Browser and navigate to Umbraco.Web.Mvc.UmbracoViewPage it says:

    public abstract class UmbracoViewPage : Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Core.Models.IPublishedContent>
    Member of Umbraco.Web.Mvc

    My solution has a "Reference" to  “umbraco.dll”  to a location outside of bin  ( C:\Clancy\A_TeraTastic\Dev\TT15\TeraTastic\App_Data\NuGetBackup\20170306-223942\bin\umbraco.dll ) and so a fresh copy should be brought in after each Clean / Rebuild All.

    So I still do not understand the reason why “  'UmbracoViewPage' could not be found  ” ???

    You can try to create a new project, and then use NuGet package to install the Umbraco.Web.Mvc.UmbracoViewPage. Then test whether it can run normally.

    Best regards,

    Sam

    Monday, July 27, 2020 2:04 AM
  • User-1224781418 posted

    Thank you Sam,

     OK I have resolved this issue and I am embarrassed to say that the solution was fairly straight forward.

    • (1) Rather than try to navigate to the file in the location listed in ……….\Temporary ASP.NET Files\....... I double clicked on the error in the Error List pane in VS to see the offending file.
    • (2) That file was not an exact copy of my source, but did have a line added near the top with the complete path to the original source file.
    • (3) In the original source file I then had to resolve the errors (remove the red squiggly lines) which in my case meant adding a “Using” statement
    • (4) One thing to note is that many pages that which worked OK before I tried to “PreCompile" the site, cause errors when being compiled by aspnet_compiler.exe. It seems a lot stricter than the JIT approach ?

    Thanks again for your assistance.

     Terry Clancy

    ClanceZ

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 29, 2020 4:41 PM