Forum Visual Studio

Problem with cshtml razor templates in Visual Studio

I did a fresh install of Windows 10 yesterday, and a fresh install of VIsual Studio 2017.3.

When I create an an Android Webapp, I get a problem with the RazorTemplatePreprocessor. Error message is

Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) App10 C:\Users\Bas Bakker\source\repos\App10\App10\App10\bakker.cshtml 1 Active
Error CS0234 The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) App10 C:\Users\Bas Bakker\source\repos\App10\App10\App10\bakker.cshtml 1 Active
Error CS0234 The type or namespace name 'WebPages' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) App10 C:\Users\Bas Bakker\source\repos\App10\App10\App10\bakker.cshtml 1 Active

The same happens when I create a Xamarin Forms application.

I could solve the problem for a Xamarin Forms application by adding references to System.Web.Razor and System.Web.Webpages. (although intellisense does not work). (I installed Webmatrix and get the assemblies from there)

However, this does not work for Android Webapp. See message below.

Severity Code Description Project File Line Suppression State
Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'System.Web.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver) App8

Suggestions how to fix this?

Thanks!
Bas

Posts

  • BasBakkerBasBakker USMember

    Clarification: this is VIsual Studio for Windows. VIsual Studio for Mac does not have the problem.

  • prashantvcprashantvc USXamarin Team Xamurai

    I’m unable to reproduce this issue using the latest Visual Studio 2017 with Xamarin tools. Please attach the following to help us reproduce this issue: 

    • Detailed reproduction steps 
    • Version information (Help → About Microsoft Visual Studio → Copy Info) 
    • Logs (Help → Xamarin → Zip Logs (last 7 days)) 
    • Optional: project to reproduce your issue
  • ZuerladZuerlad DEMember

    I have the same problem as BasBakker above.
    Projekt won't compile. 9 Errors only in RazorView.cshtml

    • Linq not found in Namespace "System",
    • Helpers not found in Namespace "System.Web"
    • WebPages not found in Namespace "System.Web"
    • CS0115 "_Page_Views_RazorView_cshtml.Execute()": No suitable method found to override.

    Details:

    • Fresh WebViewApp (Android) Template out of the box.
    • Out of the box, there are referenced

      • Mono.Android
      • mscorlib
      • System
      • System.Core
      • System.Web.Services
      • System.Xml
      • System.Xml.Linq
    • Path of reference assemblies are as follows: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll

    • Path of assembly Mono.Android is: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v7.1\Mono.Android.dll
    • Target Framework (in Projekt Properties): Use newest platform (Android 7.1 (Nougat))

    Versions:
    Visual Studio:
    Microsoft Visual Studio Community 2015, Version 14.0.25431.01 Update 3
    Microsoft .NET Framework, Version 4.6.01038

    * Visual C# 2015   00322-20000-00000-AA422
    * Microsoft Visual C# 2015
    
    * Visual C++ 2015   00322-20000-00000-AA422
    * Microsoft Visual C++ 2015
    
    * ASP.NET and Web Tools 2015.1   14.1.21111.0
    * ASP.NET and Web Tools 2015.1
    
    * ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
    * For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563
    
    * ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
    * For additional information, visit http://www.asp.net/
    
    * Microsoft .NET Core Tools (Preview 2)   14.1.21111.0
    * Microsoft .NET Core Tools (Preview 2)
    
    * Mono Debugging for Visual Studio   4.6.8-pre (ec7034f)
    * Support for debugging Mono processes with Visual Studio.
    
    * NuGet-Paket-Manager   3.5.0
    * NuGet-Paket-Manager in Visual Studio. Weitere Informationen zu NuGet finden Sie unter "http://docs.nuget.org/".
    
    * PreEmptive Analytics Visualizer   1.2
    * Microsoft Visual Studio-Erweiterung zur Visualisierung aggregierter Zusammenfassungen vom PreEmptive Analytics-Produkt.
    * 
    * Xamarin   4.6.0.299 (b63523e27)
    * Visual Studio-Erweiterung, um Entwicklung für Xamarin.iOS und Xamarin.Android zu ermöglichen.
    
    * Xamarin.Android   7.4.0.21 (2851083)
    * Visual Studio-Erweiterung zur Unterstützung von Entwicklung für Xamarin.Android.
    
    * Xamarin.iOS   10.12.0.20 (80b8487)
    * Visual Studio-Erweiterung, um Entwicklung für Xamarin.iOS zu ermöglichen.
    
    • Installed Android SDK:
      • Android 7.1.1 (API 25): SDK Platform, Sources for Android SDK
      • Android 7.0 (API 24): SDK Platform, Sources for Android SDK, Google APIs
      • Android 5.0.1 (API 21): SDK Platform
      • Android 4.4.2 (API 19): SDK Platform, Google APIs
      • Extras: Android Support Repository Rev. 47
  • prashantvcprashantvc USXamarin Team Xamurai

    I am not able to reproduce this issue on my test machines, see https://gist.github.com/prashantvc/bcfa62568a14c8a91ebce04e6807a0b0

    Could you file a new bug at https://bugzilla.xamarin.com/newbug

Sign In or Register to comment.