Problems installing Roslyn Preview - visual-studio-2013

I am having some troubles installing the Roslyn Preview.
I am using VS 2013 Premium.
I've download the package from the site and installed the vsix and everything goes well no errors.
But even after restarting VS it still does not recognize the new language features.
Tried that 3 times. Even restarting the machine but nothing works.
Does anyone knows how to correct that?
Thanks
==== Added for clarification as requested ====
The code does not compile. It complains on the code as the preview didn't exists.
In the following simple sample:
if (int.TryParse(value, out int result)) { ... }
It complains with the "int" and does not declare the result variable.
In other words it is still using the old syntax.
Just for additional information I also have Resharper v8 installed. I don't know if it is relevant (should not be actually).

I've manage to solve the conundrum.
Restarting Visual Studio is not enough. You have to create a new project.
Even if you want to use the Preview in an existing project you have to create a new project and just discard it.
After that reopen the previous existing one and the compilation will proceed with the new standards.
One note about Resharper:
Since Resharper does not yet recognize the new syntax it will color the "errors" in red and put the squiggly line but now the code is compiling and the build does not generate any errors.

Related

After a short while Visual Studio no longer accepts semicolon

When I start up Visual Studio 2013 everything works perfectly, then after 10-20 minutes it stops allowing me to type semicolon but everything else sill works. I can copy/paste semicolons from elsewhere in the source file, but this is a real pain.
It has been doing this for a few days. I didn't manually update anything recently.
I tried clearing the Resharper cache and even disabled Resharper altogether just in case but the problem keeps on happening.
Help!!!
I finally discovered what my problem is. I am writing a reusable library and want to build .Net 4.0 and .Net 4.5 versions from the same source code. I achieved this by creating two projects in the same folder that reference the same source files but are configured to target different frameworks, and use different bin and obj folders.
This setup seems to work really well for the most part, but it appears to really confuse the Visual Studio intellisense system because when you open a source file and edit it, Intellisense doesn't know whether to make suggestions from the .Net 4.0 or 4.5 framework because the source file belongs to both projects.
I solved my semicolon problem by unloading the .Net 4.5 project whilst editing and debugging the code, then reloading it when I want to make a release build.

Visual Studio 2015 or 2017 shows IntelliSense errors but solution compiles

We are currently evaluating the new Visual Studio 2015 and encountered a strange problem with IntelliSense. When I compiled our main solution with the new studio the build succeeds, but nevertheless 6 errors are shown.
I discovered that it's not a real error, but only an intellisense error. The code is definitely correct and everything compiled successfully. The code however is marked red and errors show up in the error list.
All 6 errors have the same origin. It's a simple constructor call. Strange enough, but there are also some occurrences of the exact same constructor without any errors.
The error message:
Code: CS1729
Message: '<the class>' does not contain a constructor that takes that many arguments.
Project: <the project name>
File: <the path to the file>
The new studio was installed on a freshly installed Windows 7 without any legacy software (no VS13).
I've already tried to clear the caches, deleted the suo file, deleted bin and obj directories, cleaned and rebuilt the solution etc. But nothing worked.
Can anyone explain that behavior to me?
I had thousands of intellisense errors and 0 build errors. After deleting .suo file and restarting VS intellisense errors are gone.
Suo file is located relatively to source in:
.vs\SolutionName\v14\.suo
According to comment: Beware that *.suo is a hidden file.
Edit: According to comments, VS2017 has the same issue, so you can use similar solution: Delete .vs\SolutionName\v15\.suo
VS2019 still has this issue. Delete .vs\SolutionName\v17\.suo
If deleting .suo still does solve your problem, then delete also all bin and obj directories in every project in the solution.
Also had this problem with a migrated project, so I referenced the Microsoft.CSharp dll. In some projects I needed to remove and add again the Reference in the project.
Ran into similar issue in Visual Studio 2017 ASP.Net Core Project. Following steps did the trick for me
Perform Clean Solution
Close VS
Delete .suo file & Delete bin/obj directories
Reopen VS
Similar problem as others, but different resolution. Posting in case I can help someone else.
Running Visual Studio 2017 15.5.2. I use Git and frequently switch branches. Several weeks ago, I started having editors show me errors (all related to types it could not find even though references were valid). Compile worked great. I confirmed the same issue in VS 2017 15.6 Preview (Jan 6, 2018). I would try to delete cache, SUO files, or bin/obj folders and no impact. At first it would appear to work. Reopen Visual Studio and everything would look good. Use "Rebuild Solution" and the IntelliSense errors would returns. I even tried uninstall/reinstall of Visual Studio.
I had the same issue on two machines, both with same version of Visual Studio.
By looking at the errors about missing types, they all appeared to come from two referenced projects. One of those references was a shared project used by just about every other project in the solution, but one of them was a small project without many references. It just so happens that the small project was also referenced by my larger shared project. In Visual Studio, I unloaded the small project and reloaded it. The errors went away! They errors did not come back on Rebuild Solution.
I then switched Git branches and the errors all came back. Fortunately I repeated the above steps of unloading/reloading the small project and the errors went away.
Every time I switch Git branches, the errors come back until I repeat that process. There are zero changes between the Git branches for the smaller project that I unload/reload. Unclear why that sequence is fixing my issue.
Also had this problem (the title, not the specific error message), as well as squiggly lines in the editor. The first squiggly line is under the first #include statement, which names a precompiled header. Intellisense fails to include the precompiled header, but doesn't list that as an error; instead it lists errors further down the file, on code that (very rightfully) relies on declarations in the precompiled header.
The reason Intellisense doesn't find the precompiled header in my environment is that the header named is not an actual file. It doesn't have to be in any other VC or gcc version I used, nor in the 2015 compiler, as long as the precompiled header settings are correctly configured. Apparently not any more for Intellisense. I'm not entirely sure it was different in 2013, maybe I just never noticed.
In the unlikely case that this would be the problem reported here, the solution is simple: create a small file with the pretend-name of the precompiled header, as specified in #include directives, and let that file include the actual name of the precompiled header.
If you wonder... why this distinction between the precompiled header name in the '#include' statement and the actual filename of the precompiled header? Precisely because it guarantees that precompiled header settings are correctly configured. Wherever a precompiled header is "#included", there is no file around that could be included. Either an actually precompiled (binary) version of the actual header is read, or the compilation fails. Obviously, a disadvantage is that it confuses people reading the code, not just Intellisense.
Visual Studio 2017
I have deleted ".suo" file from location .vs\SolutionName\v15.suo
And then restarted Visual studio. This worked for me.
Today I've had similar problem with MSVC++ 2015. I almost gave up and decided to go on without IDE hints, but suddenly I've noticed that stdafx.h of the project i had problems with doesn't contain any standard library headers. I've speculated that inclusion of all standard headers used in the project in stdafx.h might boost up compilation speed, however doing so fixed Intellisense errors as well.
In Visual Studio 2019 the problem is with changing branches with Git when there are NuGet packages installed in the project. What I did to solve this:
Clean Solution
Close Visual Studio
Delete the packages folder
Open Visual Studio
Go to Package Manager
Restore all packages
Recompile
If roslyn is missing, close and open Visual Studio, then recompile.
I had multiple stdfax.h in Additional Include Directories. Make sure the stdafx.h you intended is first in your path.
I had a similar issue with different Visual Studio versions.
Deleting the .suo or .vs folder did not help for me.
The Solution for me was, that I had the Extension StopOnFirstBuildError active. After turning off "Stop build on first error" in the build menu, and after the solution was fully built, the errors shown by Intellisense went away.
I was seeing the intellisearch errors only when publishing a website. (ASP/C# site, VS 2017). They broke the publish. Site ran fine locally.
Cleared the errors by unchecking the setting to pre-compile, and it published fine.
Publish -> Setting -> File Publish Options -> Precompile during publishing
I had this issue with a reference to another project. Removing and re-adding the project reference worked for me.

Creating a Functional Parser in F# using Visual Studio 2013 with FsLex and FsYacc

I have been struggling for a while simply getting a parser to compile and work in F# Visual Studio 2013. I've read a lot of other posts already that seemed helpful, both on stack overflow and this page: https://en.wikibooks.org/wiki/F_Sharp_Programming/Lexing_and_Parsing but nothing is working. I know how to write a parser and everything I just cannot get anything to compile correctly, and creating .fsl and .fsp files in Visual Studio 2013 does not seem very intuitive. This link: https://github.com/fsprojects/FsLexYacc/tree/master/tests/LexAndYaccMiniProject was helpful but it is missing Lexer.fs, Parser.fs, and Parser.fsi. Any help towards this would be greatly appreciated. I have been using the FsLexYacc package that can be installed on the package manager. Thanks in advance.
Edit: Trying to improve the question by adding some more information.
1) In Visual Studio I created a new Console Project and imported the FsLexYacc package
2) I made a .fs file that contains type definitions and such just like in the examples in the links posted above
3) This is where I'm having trouble. I know what to put inside of a .fsp and a .fsl file, but I do not know how to create them in visual studio and get them to compile correctly using the FsLex and FsYacc tools. The github link above goes into a little detail about editing the .fsproj file, but nothing that I've tried has worked. I'm assuming in order to get the tools to create the .fsp and .fsl files that the tools create them from a plain .fs file, but I'm not sure and I don't know exactly how to do that, so clarification would be great.
To reproduce my problem, either follow the steps on the wiki page or copy the files from the github link to a new project, I can't get either to compile regardless.
This question is similar to mine but I also could not get mine to work following these answers: Using FsLex/Yacc in Vs2013

NuGet Issues - Updating a package breaks build

I am going to lose my mind. NuGet has decided that any attempt to update a package destroys my Solution. I am running Visual Studio 2013 Ultimate w/ Update 3. I have been working on this solution/application for over a year and had no troubles. This weekend NuGet started breaking my solution build every time I update a package, regardless of what package I update. Say, for example, I update AutoMapper. It tells me that it updates successfully but when I build it fails to find the assembly/reference. I then start having problems with all of the other NuGet Package references. I sometimes get errors that there are syntax errors with MsBuild, target framework version errors, etc. I have tried reinstalling Visual Studio 2013, uninstalling resharper, reinstalling resharper, clearing NuGet cache, Visual Studio 2013 component cache. I am out of ideas short of rebuilding my machine.
Any thoughts?
UPDATE: 09/02/2014
I tried this process on a brand new machine and I got a lot further. I still, however, do have the following problem with my build. This problem seems to happen on every machine.
Error 4 Invalid static method invocation syntax: "[MSBuild]::MakeRelative($(MSBuildProjectDirectory), C:...\Source\packages\AutoMapper.3.2.1\lib\net40\AutoMapper.Net4.dll)". Method '[MSBuild]::MakeRelative' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(a, b)). ChoiceMentor.Presentation.Services
In this particular case, the answer was that a comma had been put into one of the file path folder names. This caused MSBuild to throw a huge fit. Renaming the folder fixed the issue. Thanks for the tips though everyone!

Using Regionerate on VS2012, or alternative addin

I tend to use Regionerate quite extensively for reorganizing my code files. My only problem is I can't get it registered with VS2012. I've abandoned VS2010 fully in favour of VS2012 and it's galling to have to flip back just to run a macro to reorganize code files. I've never tried writing a VS addin before so I'm not at all familiar with the object model or how to register - seems the old addins are more complicated to install than the VS2010 extensions! I've also looked through the WIX setup XML and tried replicating the registry keys to no avail.
Does anyone know how to either register Regionerate with VS2012, or is there an alternative (free and which is maintained!) extension that provides the same functionality?
Two things needed for registration:
It looks like VS2012 doesn't read from the HKLM...\11.0\AutomationOptions key at runtime, only at first run. The corresponding key at HKCU...\11.0_Config\AutomationOptions needs to be set as well.
A new .AddIn file needs to be created with a Version of 11.0
If you do that, Regionerate will appear, but will hang Studio when you try to use it. The Regionerate code has a bad version check ("not equal" instead of "less than") that will get stuck in code that doesn't work for VS2010/2012. Unchecking "Automatically collapse regions" in Regionerate settings might be enough to avoid the bad code.
I made a new version that fixes the version check and has the correct install pieces for VS2012. You can download the installer and changed source files here:
https://skydrive.live.com/redir?resid=2FEB8D1988F04D77!565
This is what you need to do to make VS2012 compatible Regionerate (0.8.0.1) by Frank Racis work with Visual Studio 2013.
Modify this file: C:\Program Files (x86)\Regionerate\Regionerate.VS2012.AddIn
Change version from 11 to 12: <Version>12.0</Version>
Add the following string value in your registry:
Location: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\AutomationOptions\LookInFolders
Name: C:\Program Files (x86)\Regionerate\
CodeMaid is a free and actively developed alternative. It has nearly all the features of Regionerate, plus some new stuff. One thing I really like is setting it to organize and clean unsaved files every time I build.

Resources