3

I'm trying out xamarin webView where you can use a razor-view as the UI. But the intellisense for the C#-code doesn't work.

Is this a known bug or am I missing something? Do I need to configure it in the webConfig-file?

The code works and builds, but when I need a model in razor intellisense won't work:

@model TestProject.Models.Model1

<html>
<head>
    <title>testProject</title>
</head>
    <body>
        @Model.Text
    </body>
</html> 

Where I write @model and @Model , it just says 'Cannot resolve symbol...'

What to do?

user3228992
  • 1,373
  • 1
  • 16
  • 31

2 Answers2

10

Close all instances of Visual Studio.

Go into your "(Visual Studio install path)\Common7\IDE\Extensions\Xamarin\Xamarin\3.9.483.0\" And rename the three files: System.Web.Razor.dll, System.Web.WebPages.dll, and System.Web.WebPages.Deployment.dll into System.Web.Razor.bad, System.Web.WebPages.bad, and System.Web.WebPages.Deployment.bad.

Search your registry with the registry editor and remove the "RazorTemplatePreprocessor" key.

Delete your solution user preferences files: (Solution Name).suo

When you start up Visual Studio, you will have your razor intellisense again!

DaveMorganTexas
  • 847
  • 10
  • 13
  • Just a comment on why I did this. Related but non-Xamarin issues pointed to a version mismatch in Views\Web.config. These files provided by Xamarin actually have the version set to 3.9.483, which is greater than the 3.0.0.0 that the files are currently at for MVC5. Removing the RazorTemplatePreprocessor key is just to prevent xamarin from having any issues from missing their copies of the dlls by keeping them from trying to use their custom preprocessing, and removing the preference files is just to remove any incompatible format changes they may have introduced. – DaveMorganTexas Aug 22 '15 at 20:20
  • 1
    In my current install of the Xamarin tools, none of the System.Web files listed above exist (4.1.0.530). Any fix for this version? – jtsoftware Jun 08 '16 at 22:32
1

We were having this issue as well and found a solution in a blog post by Michael Ridland in the form of a project called MVCPolyfils. The post and the .git repository can be found here: https://github.com/rid00z/MVCPolyFils

We added it and updated the references in our .cshtml headers and the whole thing works a treat now - such a relief!

  • 3
    Please quote the relevant section in your answer. Linking to external sites should be just for citing them, the relevant information should all be on Stack Overflow. – SuperBiasedMan May 20 '15 at 10:34