At work we have a C# solution with over 80 projects. In VS 2008 we use a macro to stop the compile as soon as a project in the solution fails to build (see this question for several options for VS 2005 & VS 2008: Automatically stop Visual C++ 2008 build at first compile error?).
Is it possible to do the same in VS 2010? What we have found is that in VS 2010 the macros don't work (at least I couldn't get them to work) as it appears that the environment events don't fire in VS 2010.
The default behaviour is to continue as far as possible and display a list of errors in the error window. I'm happy for it to stop either as soon as an error is encountered (file-level) or as soon as a project fails to build (project-level).
Answers for VS 2010 only please. If the macros do work then a detailed explanation of how to configure them for VS 2010 would be appreciated.
(You can now download this as an extension, if you don't want to build it yourself)
This answer only works in VS2010 (seems fair :]). I've put the source up on my github page. Before you can build it, you'll need to install the SDK. Once you've done that, just grab the complete source from github (includes project files) and build that. You can install the output into your normal VS instances by finding the VSIX in your build output and opening it.
The important part is:
public void TextViewCreated(IWpfTextView textView)
{
var dte = GlobalServiceProvider.GetService(typeof(DTE)) as DTE;
textView.TextBuffer.Changed += (sender, args) =>
{
//Output window is friendly and writes full lines at a time, so we only need to look at the changed text.
foreach (var change in args.Changes)
{
string text = args.After.GetText(change.NewSpan);
if (BuildError.IsMatch(text))
dte.ExecuteCommand("Build.Cancel");
};
}
}
... where BuildError is a regex defined above that you can tweak. If you have any questions about modifying the code, let me know.
Edit: See now that Will beat me on this one - For VS2010 there is an add-in available that can do this, and lots more. VSCommands 2010, via http://vscommands.com/features/
Check my reply here.
I know this might be bit late, but if it helps anyone then they should install the extension VSColorOutput
Then go to Tools => Options => VSColorOutput => General => Set Stop Build on First Error to true.
Hope this helps, happy Debugging!
Related
I use Visual Studio 2017 (15.6.6). When debugging, I try to evaluate simple expressions like int a = 2; in the immediate window. An error
Internal error in the C# compiler
is thrown.
I tried to enable Use Managed Compatibility Mode as hinted at in this question but it didn't help.
Thanks for any help.
Searching further I found this issue on GitHub where an answer recommends to also check Use the legacy C# and VB expression evaluators. Visual Studio gives me a warning about checking this option, but turning this on I can evaluate expressions in the immediate window again.
It is even possible to turn off the Use Managed Compatibility Mode again.
Update: Notice though that using the legacy expression evaluators prevents me from inspecting local variables at debug time, so I wouldn't call it a solution.
In my case, the problem was occurring in a particular assembly. When we looked at the assembly information, (from the Solution Explorer, right click on project, select Properties, then click on Assemble Information), it was all blank.
So we gave it a Guid, then re-built and it worked.
I had the same issue. Don't know if it's your option but for me it was the next issue: instead of "Debug" version the "Release" was turned on. So as soon as I switched back to debug I got rid of this error.
I've got the same error when deal with own NuGet package.
In my case VS resolve a path to the copy of my assembly in "%userprofile%.nuget" folder instead of build output folder.
Currently, I don't known how to prevent this miss-resolving for new project types, where no hint is specified for references, but there's simple workaround: just remove unpacked copy of package from %userprofile%\.nuget\packages\%yourpackage% before debug.
It is happening in Visual Studio 2022 17.3.2 too and it can be found "Closed, not enough info" on feedback hub. As always, incompetent outsourced india strikes again.
Anyway stopping debugging and rebuilding solution works. It have something to do with completely f****d and useless Hot Reload.
Clearing the directory C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files solved the issue for me. I'll try to build a repo if the issue appears again...
I want to experiment with the potential C# 7 future language features.
I have a virtual machine into which I have downloaded the Roslyn codebase (features/patterns branch) and built as described on Roslyn's github here: Building and Testing on Windows.
I can successfully fire up a new experimental instance of Visual Studio (set VisualStudioSetup as the startup project and run).
When I try out the new language features (pattern matching and local functions) I get an error in the editor as a squiggly and also error when I build:
Error CS8058 Feature 'local functions' is experimental and
unsupported; use '/features:localFunctions' to enable.
Error CS8058 Feature 'pattern matching' is experimental and
unsupported; use '/features:patterns' to enable.
Where do I put these options?
I tried adding it to the command line arguments, but I get an error.
This is bug 7812 that I haven't fixed yet. Sorry.
Internally, the compiler team mostly just tests things through unit tests or the command line compiler; if we really need to test the IDE we just delete the check that's passing in the feature flag.
Sorry, I haven't done R&D with the said code you have downloaded.
But in Visual Studio '15' preview (announced on 30 March 2016) I have fixed this very easily. It might help other people.
I was getting the error
Error CS8058 Feature 'local functions' is experimental and unsupported; use '/features:localFunctions' to enable.
To fix this select your project name and right click >> Properties Window >> Build and then
add the below two options in "Conditional Compilation symbols" text box __DEMO__,__DEMO_EXPERIMENTAL__
click on save button to Save it. Now build your application and your build will be succeeded.
Even though at my end if I add any one of the __DEMO__ & __DEMO_EXPERIMENTAL__ then it is working fine.
I found way to enable the new language features.
By tracing the code I found where the feature check is made (function IsFeatureEnabled) and changed it to always return true.
Then I rebuilt from the command line as before. And after that the new language features are enabled when I fire up the experimental Visual Studio instance.
BEFORE:
AFTER:
internal bool IsFeatureEnabled(MessageID feature)
{
// Force all demo features:
return true;
// in "demo" mode enable all language features.
if (PreprocessorSymbols.Contains("__DEMO__"))
{
return true;
}
I have Visual Studio 2013 with no plugins or anything fancy. Whenever I'm coding, every so often (maybe once every half hour) intellisense randomly stops completing my sentences or popping up at all when I press Ctrl+Space.
I have tried Tools->Import and export settings->Reset all settings but it did not help. The issue came right back.
The only thing that solves it for me now is to close VS and reopen it. But as you can imagine, this is extremely frustrating.
I was having the same problem and this seemed to work for me.
http://omegacoder.com/?p=1008
Basically, go to Tools >> Options >> Text Editor >> All Languages >> General and make sure that both Auto list members and Parameter information are checked (not the half-checked/square state).
This is still happening in VS2013 update 4 (I have a WPF project using C#).
This was relatively easy to fix by closing then reopening the file not the whole project.
For me, Unloading and Reloading a project fixes MVC cshtml intellisense. Right-click project, click Unload. Right click grayed out project, click Reload.
Just to be clear, this problem only happens to me when in C# MVC views, only when checked into TFS.
I have also submitted this as a bug to Microsoft, see https://connect.microsoft.com/VisualStudio/feedback/details/932855/vs-2013-c-default-mvc-template-breaks-upon-checkin-to-tfs-2010
Looks like my issue cleared up after deleting the settings folder from my previous VS2010 installation. I followed the instructions here (Also applies to VS2013): http://www.haneycodes.net/visual-studio-2012-intellisense-not-working-solved/
In case URL breaks:
Open the start menu and type “%AppData%” and press enter to get to your Application Data Folder.
Either you were automatically placed in the “Roaming” folder or you weren’t. If you weren’t, go to the “Roaming” folder.
Open the “Microsoft” folder.
Open the “VisualStudio” folder.
Here you’ll see a folder titled “11.0” (the VS 2012 folder) and probably also “10.0” (the VS 2010 folder).
DELETE (or rename) the “10.0” folder. Note that you can now kiss your Visual Studio 2010 settings and preferences goodbye (your projects will be safe and sound).
DELETE (or rename) all other folders that are not the “11.0” folder, assuming you used to have Visual Studio 2008 or whatever.
Now restart Visual Studio 2012 and you should be good to go!
try to delete the .suo file of your solution. It worked well for me.
The first thing I should mention is that this hasn't happened since I've upgraded my RAM. I was at 4GB when this was happening. Often had multiple instances open as well as SQL Server.
I'm finding this seems to happen when I copy/paste controls on a page. Another side affect of this is that the designer.(cs/vb/xx) file is not updated right away and I don't have access to those controls in code behind.
I've tried a handful of things and here's a summary of what I've found so far:
If only 1 file/window appears to be affected, close/reopen that file.
If that doesn't work... in Visual Studio:
Click Tools->Options->Text Editor->All Languages->General
Uncheck "Auto list members"
Uncheck "Parameter information"
Check "Auto list members" (yes, the one you just unchecked)
Check "Parameter information" (again, the one you just unchecked)
Click OK
If this doesn't work, here's a few more steps to try:
If still not working, close all windows and reopen
If still not working, close/reopen solution
If still not working, restart VS.
(I haven't yet figured out why more drastic steps are required in some cases.)
For C++ projects:
MSDN has a few things to try: MSDN suggestions
The corrupt .ncb file seems most likely. Note that in VS2013 and later, it is the .sdf file, which can be found in the root folder. Try searching for filename:*.sdf.
From MSDN:
Close the solution.
Delete the .ncb file.
Reopen the solution. (This creates a new .ncb file.)
Notes:
Tested in VS 2013/2015
Logging possible causes:
Copy/pasting controls in a source page. I found that my designer.vb file didn't update from this, either.
Copy/pasting code from another page that caused an error because the code copied referred to a control that wasn't on the page I was pasting to.
C++ project has corrupt .ncb file
Like cacau says, you must first do a clean of the entire solution. Then restart VS rebuild the entire solution.
This sometimes happens when you are using Entity Framework or WCF services (Or the combination)
VS generates a lot of files then that contain code (the service reference for example). When you regenerate that code (And for example you are running a web project) sometimes you forget to stop the site. Then VS can't overwrite every file. Resulting in a global intellisense failure.
For me, the problem happens when I have two instances of same solution opened. On one of them I'm running Tests, while on the other I am making tweaks to code. Intellisense will quit working on me usually after I've run some tests and stopped the debug session manually.
The solution for me is to close all VS windows and reopen...
Did you try a clean build on your project?
VS might have become confused with some of its generated files..
None of the solutions in this thread worked for me.
what worked was that I deleted everything in the packages folder. when I rebuilt the solution, nuget got the latest versions of all the folders I deleted, and intellisense started working fine.
If I am not mistaken, the problem initially was caused by the contents of the "Microsoft.Net.Compilers.1.0.0" folder, but I dont know why.
If you have this problem in one file, make sure that this file is included in your project. Right Click the file, Select Include In Project. If the file is not included in your project, VS will treat it as a normal text file.
I followed the instructions given in response to the question : Visual Studio 2012 - Intellisense sometimes disappearing / broken (thanks to SajjadHashmi and others). I've copied the steps I followed (which worked for me) here in an attempt to be helpful.
1: Close all the tabs and open your file again. (Thanks to russds)
2: Clean the Build > Close the Solution > Restart Visual Studio > Open the Solution again
Further steps are listed if you follow the above link but some seem to no longer apply to Visual Studio 2013 (e.g. refresh Local Cache for intellisense).
I know that these steps involve restarted Visual Studio (which you are explicitly trying to avoid) but for those who find your question (such as me) a potential solution might be useful.
In case anyone else fell into the black hole I did ... I too suffered from this issue but NONE of the above solutions worked for me. Eventually I figured out that somehow the opening <body> tag had been deleted from my .Master page and that was causing all my .aspx pages to lose 95% of the Intellisense code hinting. Once I added the missing <body> back to my .Master page, the Intellisense finally started working in my .aspx pages again! Hope this helps someone ... just cost me 1.5 hours!
Sometimes none of suggestions here works - at least that happened to me.
But don't rush with configuration resetting, cleaning up visual studio configuration files and so on. If clean/re-build + vs restart does not work - problem might be in code itself.
In my case (vs2013) I had C++ class exposed in .h like this:
class MyClass: ...
{
....
DLL_EXPORT returnArgs function(InParameters)
}
where DLL_EXPORT is defined as :
#define DLL_EXPORT __declspec(dllexport)
Same function in .cpp:
returnArgs MyClass::function(InParameters)
{
}
vs2013 was refusing to jump between function definition / implementation.
Reason seemed to be DLL_EXPORT macro - I've written function like this:
DLL_EXPORT returnArgs MyClass::function(InParameters)
{
}
After that intellisense started to work again.
It's possible also to remove that define or wipe it out - according to visual studio documentation __INTELLISENSE__ - but that define did not work for me for some reason. Code snipet like this:
#ifdef __INTELLISENSE__
#define DLL_EXPORT
#else
#define DLL_EXPORT __declspec(dllexport)
#endif
Please comment if you understand why this does not work.
In vs2015 this issue seems to be fixed, but there are other problems with vs2015.
None of these things worked for me. After lot of struggle I found why it was not working for me. I always had multiple solutions open in my machine. For suppose, One solution is for front-end layer and another solution is for back-end layer.
When it hits breakpoint kept in backend service layer intellisense was not showing up. After I closed all other solutions and rebuild the solution where I wanted to debug, everything worked fine.
There could be other reasons, but this worked for me and wanted to let this community know and it may help someone.
EDIT: Few times "delete all breakpoints" and adding again worked.
I had the same problem and in my case it was the same file being open twice. For example I have dev\include\myfile.h AND dev\include\myfile.h\ (note the backslash, making this a unique string).
This happens when I use F12 to find a symbol in an include file, but also have the original .h file open already; Visual Studio opens up a duplicate file, which is really the same file.
When saving either of the two instances, the changed file date will be noticed and I get a popup asking whether I want to reload the other instance. More problematic seems that it also confuses IntelliSense. I just tried closing all duplicate instanced files, and IntelliSense started working again without restarting or reloading anything.
I tried to fix my problem by solution VS2013 Intellisense constantly stops working
But it did not work for me.
Solution that worked for me is off/on Auto list members
Go to Tools > Options > Text Editor > General
I have Microsoft Visual Studio Professional 2012 installed, version 11.0.60610.01 Update 3.
When debugging a c# (.cs) file Visual Studio gives me the following message when I try to set a breakpoint:
"A breakpoint could not be inserted at this location".
I get this message even when trying to set it on a line within a method. But in a .vb file for a Visual Basic app, I can set a breakpoint.
I am wondering if anyone has any suggestions to resolve this or if I need to reinstall visual studio.
Thanks
Maybe I'm too late for this question but here it goes anyway,
BUILD > Clean Solution
BUILD > Build Solution
I have encountered a similar issue and I resolved it by exiting Visual Studio and deleting the .suo file from my solution folder.
This file is recreated when you open the project again and it is not harmful to delete it.
The .suo is used for storing the layout of your solutions, the breakpoints you've set, the tabs you had open, etcetera.
I am not sure why this worked but my logic was that Visual Studio thought I was trying to place a breakpoint in a location different to where I was actually placing it.
I was finally able to find a solution for this. I had to do a repair on my Visual Studio 2012 instance through the control panel -> Programs and Features, right clicking on Microsoft Visual Studio Professional 2012, and selecting change. In the Visual Studio window I then selected repair.
As part of the repair process, I also had to download web deploy located here: http://www.microsoft.com/en-us/download/details.aspx?id=4148 and point the visual studio repair process to the .msi file when it said it couldn't find the web deploy package and could not download it from the internet.
I also had to implement the fix indicated in the following stackoverflow question: Plain C# Editor in Visual Studio 2012 (No intellisense, no indentation, no code highlighting)
Now I am able to debug applications as expected.
Well, sheesh...for people as dumb as me, here's one more thing to consider:
You can put breakpoints on the curly braces at the start or close of a method, and you can put breakpoints on any line that is doing something (e.g. assigning a value or calling a method). However, you can't put a breakpoint on a line that is only declaring a variable or otherwise "doing nothing."
E.g. I had a method:
public IEnumerable<SomeObject> GetList()
{
int distance;
var otherVar = SomeValue;
}
I was trying to put the breakpoint on the first line with int distance;, which is something that works fine in other IDEs, but that doesn't work in VS. I had to go up to the brace or down to the next line with the assignment in order to get the breakpoint to set.
5 minutes of my life wasted, that I'll never get back, trying to debug a non-issue ;-p
VS 2017
I had this, I was missing an ; inside a for loop
If there is no instructions to execute on a line, VS refuses to set a breakpoint an offers no reason. EG
string str; //Cannot set breakpoint
string str = ""; //Can set breakpoint
I'm trying to get a list of all projects within a specified VS2008 solution. (this is a stand-alone console app, it is not a Visual Studio add-in)
My code works with VS2005 solutions, but I get all sorts of ugly COM errors trying to use the VS2008 object.
What I mean is:
This:
Type _visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.8.0");
DTE _dte = Activator.CreateInstance(_visualStudioType) as DTE;
works and this:
Type _visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.9.0");
DTE _dte = Activator.CreateInstance(_visualStudioType) as DTE;
doesn't (currently throws COM error 8001010a)
I have both relevant classes registered in the registry, and all appropriate assemblies are referenced.
Edit: I'll go with basic parsing of the .sln file, even if I have to do a bit of rewriting, as text manipulation is bound to work without all the nasty interop stuff.
However, I can't seem to find a description of the .sln format, any resources?
You may want to look at this: Library for parsing Visual Studio Solution files? If parsing the .sln directly turns out to be your only option.
As to your current problem, some other people have had your issue. The KB246018 says check out your antivirus as the leading cause (example is word, but same applies to VS). Try excluding the VS directory entirely.
You are getting an RPC error: "server is busy". That might be because Visual Studio is actually busy, debugging your console mode program. Short from debugging with Console.WriteLine() statements, try another debugger. The Windows SDK has the clrdbg.exe and mdbg.exe debuggers. The .NET 2.0 SDK had a GUI debugger iirc.