An error occurred while compiling the views
Hello I get an error the following error only in apphb.
Microsoft (R) ASP.NET Compilation Tool version 4.0.30319.33440
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.
D:\temp\vomausrm.s50\output\_PublishedWebsites\TicketsApp.Host\Areas\HelpPage\Views\Help\DisplayTemplates\Samples.cshtml(6): error CS0012: The type 'Dictionary<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
[HttpCompileException]: D:\temp\vomausrm.s50\output\_PublishedWebsites\TicketsApp.Host\Areas\HelpPage\Views\Help\DisplayTemplates\Samples.cshtml(6): error CS0012: The type 'Dictionary<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
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.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)
Website precompilation failed with exit code 1. Precompilation can optionally be disabled in your AppHarbor application settings
https://appharbor.com/applications/ticketsapidev/builds/1682882
In my local pc works fine, and I also I took a look to roselyn example and it is compiling ok all c#6 features.
Discussions are closed to public comments.
If you need help with AppHarbor please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by rune on 16 Feb, 2016 07:48 AM
Hi,
Do you precompile your view locally as well? This is a runtime error, so you might not experience it unless you visit that website while testing locally, or precompile the application. You may want to disable precompilation to see if the app will work on other parts of your site.
The error message does point out that a specific reference is missing, so perhaps it can be solved simply by adding the reference as specified (*"You must add a reference to assembly 'System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'."*). If you've already done that I suspect the change may not have been committed to the repository, so perhaps you can verify whether that's the case?
Best,
Rune
2 Posted by ibanezjp on 17 Feb, 2016 02:31 AM
All site pages are working on dev environment. I disabled precompilation in apphb and then the site built successfully in apphb but when I browse the web page it fails, with the same error message.
Then I added 'missing' referece in web.config and I worked fine (with precompilation disabled).
I enabled precompilation again and the site in apphb is still precompiling the views.
Support Staff 3 Posted by rune on 17 Feb, 2016 01:26 PM
Ok it's a bit odd that the issue wouldn't be present locally if you had to add the reference to make it work on AppHarbor -- but the problem is solved now, right?
Best,
Rune
4 Posted by AntonyBaasan on 03 May, 2017 05:48 PM
I had the same issue. .NET 4.6. Added assembly line on a web.config file.
http://stackoverflow.com/questions/29575216/assembly-not-referenced-compilation-error-in-foreach-loop-in-razor-view
Support Staff 5 Posted by rune on 04 May, 2017 03:52 AM
Hi,
Thanks for sharing your solution and the Stack Overflow link -- might come handy for other users!
Best,
Rune
rune closed this discussion on 04 May, 2017 03:52 AM.