Razor intellisense not working in VS 2015 - razor

When I load up my VS2013 projects in 2015, all my razor views are filled with red squiggly underlines.
#model, #Scripts #url, #Html.Partial, lambda expressions
Intellisense is now fairly useless as it seems to be missing half the options.
Solutions I've seen involved deleting .vs folder, and devenv.exe /ResetUserData, however these don't work for me.
I'm on a fresh install of VS 2015 Community using the same install files as my colleagues. None of them have the razor issues, and they're working on the same projects as I am.
Any idea how to fix this?
Edit...Further Info!
I uninstalled/reinstalled VS 2015 Community, opened my projects, and the razor worked!
I then clicked on a notification saying to update NuGet. NuGet update installed, VS restarted, razor stopped working again. So the NuGet update is breaking razor??
Every time I open a razor file it says "An exception has been encountered. This may be caused by an extension. You can get more information by examining the file 'C:\Users\Jonathan\AppData\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml'.
"
In the activity log I get the following error
"System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Item has already been added. Key in dictionary: 'RazorSupportedRuntimeVersion' Key being added: 'RazorSupportedRuntimeVersion' at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Collections.Hashtable.Add(Object key, Object value) at System.Collections.Specialized.HybridDictionary.Add(Object key, Object value) at Microsoft.VisualStudio.Utilities.PropertyCollection.AddProperty(Object key, Object property) at Microsoft.VisualStudio.Html.Package.Razor.RazorVersionDetector.Microsoft.Html.Editor.ContainedLanguage.Razor.Def.IRazorVersionDetector.GetVersion(ITextBuffer textBuffer) at Microsoft.Html.Editor.ContainedLanguage.Razor.RazorUtility.TryGetRazorVersion(ITextBuffer textBuffer, Version& razorVersion) at Microsoft.Html.Editor.ContainedLanguage.Razor.RazorErrorTagger..ctor(ITextBuffer textBuffer) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstance(Type type, Object[] args) at Microsoft.Html.Editor.ContainedLanguage.Common.ContainedCodeErrorTaggerProvider`1.CreateTagger[T](ITextBuffer textBuffer) at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)"
How do I fix this?

You dont need to reset the entire configurations of your Visual Studio using the devenv.exe /ResetUserData to workaround this
Instead of it, try to just delete the contents of this directory with Visual Studio closed then reopen it:
%LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache

Here's what FINALLY worked for me:
Start -> Run -> (Or Windows Key + R)
Then type "devenv.exe /resetuserdata" (no quotes of course)
I did not have to delete the .vs file, as some others had experienced.
See also: Visual Studio 2015 Broken Razor Intellisense

I've upgraded to mvc5 and so forth to razer 3. It solved my issue.
I followed this instructions :
http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-21

Had the same issue. ResetUserData didn't work, etc. What ResetUserData did do though was reset some of the dialogs that were suppressed. Ultimately a dialog popped up stating "The 'CompatiblityCheckerPackage' did not load correctly." It told me to go to my users folder (path below) and check out the ActivityLog.xml. Turns out WebEssentials 2015 did not install correctly and was failing to load. I installed WebEssentials again and the Intellisense errors went away.
Full Path for me:
C:\Users\xxx\AppData\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml
Hope this helps.

This could fix similar problems (I got it from somewhere, unfortunately I cannot remember, on Github)
Close VS Studio
Run command prompt as Administrator
In command prompt:
> cd "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE"
> devenv /updateconfiguration
> devenv /clearcache
I hope the above will be helpful to someone.

Deleting the entire Solution and re-downloading it from Source Control is the only thing that worked for me. You might need to open the solution in VS 2013 first before you can open it in 2015... a very buggy Visual Studio release Microsoft!
Edit:
Another thing that is strange, at least for me... deleting the red zigzag underlined text then retyping it fixed the problem! Possibly just a random thing that happened to me.

I had same issue and none of these answers worked. What I finally saw was, my Views web.config file was referencing MVC 4, and my main web.config was referencing MVC 5. So I could compile fine but intellisense wasn't working. MVC 4 isn't supported in VS2015. Why my web.config files were different I don't know. When I updated MVC in VS2012 months ago it must not have updated that config file.

You don't to update anything.
Just delete component cache from this folder
C:\users\xxx\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
And ot will work fine .
Try it

None of these solutions fixed it for me. What worked was ensuring my webpages version was up to date. So
<add key="webpages:Version" value="3.0.0.0" />
in the web.config, instead of version 2.0.0.0
And then closing and reopening visual studio with the same solution.

I know that this topic is out of date, but I've just overcome the same problem and my resolution is not related to any one of the listed here.
The issue is that in my project properties the parameter "Output path" (Build->Output) was a folder different from just "bin\". After changing it to bin\, reopening the Studio and rebuilding my project, everything worked out!
Hopefully, it might help someone.

I am using VS 2015 professional. Faced the same issue, tried all mentioned above solutions and nothing worked. Neither "devenv.exe /ResetUserData" nor "deleting content of ComponentModelCache".
The only way I managed to solve the issue is by modifying the installation:
Go to Program and Features -> Find Microsoft Visual Studio ... 2015 -> Click Change -> Select Modify -> Check "Microsoft Web Developer Tools" -> Click Update
That worked for me.

i have read a lot of solutions, a i have lose much time, and when i was sure to not resolve the problem of visual studio 2015 intellisense, eureka, some one was giving the right solution:
lean & clear 2 lines of code those I run in cmd (like administrator):
C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE>devenv /updateco nfiguration
C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE>devenv /clearcac he
whe restart visual studio maybe it ask to reinstall one tools that was broked.
Well you do but still fron now your intellisense is going work agane.
good luck at all and much thanks at Nadir

Just do one thing and go to:
Tools > Extension & Update > Update Your Visual Studio Version
It take some time but after that working fine.

Just Put a Break point on the First line
of Page. and remove it after few seconds... it will definitely work...

Related

SSIS - Mapping of paramater values to a configuration does not work

I'm using the latest version of Visual Studio Community 2019 (16.11.8)
together with SSIS extension 3.15 and at some point in time (can't say exaxt date/time)
the possibility to map project parameters to a configuration stopped working.
I can add new parameter mappings using the dialog but when clicking ok and reopening the dialog, the parameter is gone. Parameter mappings added earlier stay unchanged.
Here an example:
Open dialog
Then add a parameter
Parameter has been added:
Close and open dialog again:
One of my colleagues tested this with same software versions, problem is the same there.
Maybe anybody already knows this or can give me a hint if I do something wrong or if there is a workaround.
Thanks in advance for any help.

SSRS project does not compile since migration - error BC30451

Since I have migrated my SSRS project to 2017, I'm getting over 300 errors like this one: "[rsCompilerErrorInExpression] The Color expression for the chart 'Chart18' contains an error: [BC30451] 'Helper' is not declared. It may be inaccessible due to its protection level."
Helper is our custom C# project including all our custom functions and properties used by the reports. I found a post that explained that I must put a copy of the dll into the folder: C:\Program Files (x86)\Microsoft Visual Studio xx.0\Common7\IDE\PrivateAssemblies\ depending on the VS version. But, I still get the same error.
I also checked the namespace but, in fact, nothing changed since years.
Any idea?
Regards,
Pascal

Monodevelop fails to build, can't find Microsoft.DiaSymReader.Native.x86.dll'

I am trying to build a web api project using monodevelop on a mac. The thing is that after a few hiccups (explained in a question that turned out to be so messy I have just deleted) I get to the point of getting this error
/Users/myuser/git/LiveData/LiveData/CSC: Error CS0041: Unexpected error writing debug information -- 'Windows PDB writer is not available -- could not find Microsoft.DiaSymReader.Native.x86.dll' (CS0041) (LiveData)
In a windows machine the same project builds using visual studio targeting mono 4.5.
When I click on the error it tells me that /Users/myuser/git/LiveData/LiveData/CSC doesn't exist
Another thing is that in the folder structure of the solution there's a package folder (not the one inside the project) and inside this one I have a folder called Microsoft.Net.Compilers 1.3.2 that has inside another folder called "tools" that contains among other things csc.exe and the dll thta can't be found.
I have tried to install the dll directly in the project using nuget but even if it was installed the build showed me the same error
Thanks,
As for workaround for now you can just limit usage of Microsoft.Net.Compilers to Release configuration (edit *.csproj file):
<Import Project="..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="'$(Configuration)' == 'Release' And Exists('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" />
take a look at beginning of condition:
'$(Configuration)' == 'Release'
This way I can build and debug locally and build my project ie. in appharbor.
Building the project in release configuration should fix it!
This might not be completely related but may be helpful in some ways. Regarding the issue on 'could not find Microsoft.DiaSymReader.Native.x86.dll', have a look at this issue on GitHub: https://github.com/dotnet/cli/issues/3016
It seems like the solution is either:
Dependency to Microsoft.NETCore.Platforms needed for RID graph which
was missing. Any package which has transitive dependency on it (like
NETStandard.Library) could also make things work.
Adding dependency to "Microsoft.NETCore.Platforms": "1.0.1-" or
"NETStandard.Library":"1.5.0-" make it work.
adding Microsoft.NETCore.Platforms works as well

Why does VS2013 sometimes throws exception 0x80070057 when closing a file?

Sometimes, not all the time, Visual Studio 2013 w/ Update 1 on an up to date Win7 x64 machine throws an exception when closing a file, or multiple files doing "Close All But This". A dialog is shown referring you to the "ActivityLog.xml" file at "C:\Users\\AppData\Roaming\Microsoft\VisualStudio\12.0" which has one of the following entries for each file that was being closed. I am using the latest version of DevExpress controls.
How can I fix this? I did not find any similar issues though post Is there something I can/should do about this VS 2013 exception? was vaguely similar but this does not happen when I open a solution.
So far, it seems to occur mostly when having multiple instances of VS2013 open but I am unable to repro at will. Clearing the ComponentModelCache did not help in that it has occurred again after clearing the cache. The solution was originally a VS2012 solution and all new DevX, MVC and EF components have been updated to latest versions with NuGet.
<entry>
<record>858</record>
<time>2014/02/17 20:22:45.177</time>
<type>Error</type>
<source>Editor or Editor Extension</source>
<description>System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at Microsoft.VisualStudio.NativeMethods.ThrowOnFailure(Int32 hr, Int32[] expectedHRFailure)
at Microsoft.VisualStudio.Shell.RunningDocumentTable.FindDocument(String moniker, IVsHierarchy& hierarchy, UInt32& itemid, UInt32& docCookie)
at Microsoft.VisualStudio.CodeSense.Editor.Roslyn.CodeElementTaggerProvider.CreateTagger(ITextView textView)
at Microsoft.VisualStudio.CodeSense.Editor.TaggerProvider`1.CreateTagger[T](ITextView textView, ITextBuffer buffer)
at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)</description>
This appears to be a bug in the Code Sense engine. They are requesting a document from the Running Document Table after the document has been closed. I encourage you to please file a bug on this (customer bugs get more attention than if I just filed it)
http://connect.microsoft.com/VisualStudio
The only thing you can do to stop this is to disable Code Sense
Tools -> Options
Text Editor -> All Languages -> Code Lens
Uncheck "Enable CodeLens"

Support multiple assemblies on ASP.NET\C# projects

We're developing a ASP.NET application and having some problems with integration with a MS dll (Microsoft.AnalysisServices)?
The original project was linked to the dll which came with SQLServer2005 (Version=9.0.242.0). After migrating to SQLServer2008R2 (version=10.0.0.0) we encountered this problem:
Could not load file or assembly 'Microsoft.AnalysisServices,
Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
or one of its dependencies. The system cannot find the file
specified.
This is understood since we compile the project with one version and then another version is located on the server. After installing SQLServer2008R2 on the development machine the problem was fixed.
However we now have another problem that we need to support both SQLServer2005 and SQLServer2008R2 environments. I know that we can redirect the search path for the dll using a config file (that it will search for a different version that what it was compiled with), but I can't seem to find instructions how to use it for Web Application (on w3wp). We tried to use "Specific Version"=false, but since this is a "Strong Name" assembly it doesn't work as one would think.
The relevant link which I found is this:
http://social.msdn.microsoft.com/Forums/en-US/sqlanalysisservices/thread/47d0b992-3c10-4851-b2a5-9f72d2c0976e
Can someone please direct me to a link for solving this issue?
Update: I guess I didn't test it correctly since it doesn't work for other servers in SQLServer2008 R2. I guess you can't use range in the newVersion element. So the question is still opened for everyone! . Bottom line is that I know that I have version 9.0.242.0 but the customers version may be either 9.0.242.0 or 10.0.0.0. Is there a method which I can dynamically choose the correct assembly on the production server
You can hook into AppDomain.CurrentDomain.AssemblyResolve and load the assembly you want. If you return null it will look for it normally.
eg.
AppDomain.CurrentDomain.AssemblyResolve += Resolve;
private static Assembly Resolve(object source, ResolveEventArgs args)
{
if (args.Name.StartsWith("Microsoft.AnalysisServices,"))
return Assembly.LoadFile("Microsoft.AnalysisServices.dll");
return null;
}
Try adding a bindingRedirect to your web.config.