How to activate the error waves in visual studio code? - c++

I recently started using Visual Studio Code for C++ (installed extensions: C++ and Code Runner), and sometimes those red error waves under the code show even though everything is correct, and then the only "quick fix"-option was to deactivate them. I was annoyed by the waves so I deactivated them - and now I do not know how to reactivate them (well, most of the time they actually were helpful)! I found nothing in the settings, even after resetting everything they did not come back.
Could you give me a hint how to activate them again?

To disable or enable wavy/squiggly underline in visual studio code, go to file\preferences
and change some settings
To disable:
{
"workbench.colorCustomizations": {
"editorError.foreground": "#00000000",
"editorWarning.foreground": "#00000000",
"editorInfo.foreground": "#00000000"
}
}
to enable: (this color is a suggestion):
{
"workbench.colorCustomizations": {
"editorError.foreground": "#ff000088",
"editorWarning.foreground": "#ffe60033",
"editorInfo.foreground": "#00ff0088"
}
}

Related

Why doesn't the c++ file run in visual studio

So I tried making a basic game on the console using screen buffers, I was able to create it and make a square move in the canvas, but for my next project I looked up a website with the ASCII characters and pasted a couple into a comment at the end of the c++ file, when I ran the file visual studio prompted:
I clicked yes and it didn't run anymore.
Also I recently have installed an extension for visual studio (before it didn't run, the extension works fine but I don't know if the extension may have caused this as I didn't tried running it with the extension downloaded and applied), when I open visual studio and open a file it says:
The last record in the ActivityLog xml file, has a type of error and it's description is:
Microsoft.VisualStudio.Composition.CompositionFailedException: Expected 1 export(s) with contract name "Microsoft.VisualStudio.CppSvc.Internal.CodeAnalysis.ICodeAnalysisService" but found 0 after applying applicable constraints.
at Microsoft.VisualStudio.Composition.ExportProvider.GetExports(ImportDefinition importDefinition)
at Microsoft.VisualStudio.Composition.ExportProvider.GetExports[T,TMetadataView](String contractName, ImportCardinality cardinality)
at
Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T,TMetadataView](String contractName)
at
Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T](String contractName)
at
Microsoft.VisualStudio.Composition.ExportProvider.GetExportT
at
Microsoft.VisualStudio.Composition.ExportProvider.GetExportedValueT
at Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetServiceT
at Microsoft.VisualStudio.VC.ManagedInterop.<>c.<Initialize>b__52_15()
at
System.Lazy`1.CreateValue()
at
System.Lazy`1.LazyInitValue()
at
System.Lazy`1.get_Value()
at
Microsoft.VisualStudio.VC.CodeAnalysis.ResultTaggerProvider.CreateTagger[T](ITextBuffer buffer)
at
Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)
--- End of stack trace from previous location where exception was thrown ---
at
Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
I have Visual Studio 2017
So why does running the file (with the local windows debugger button) say that there were build errors? And how can I fix it?
When it prompts the build error, and I click no it usually shows the errors but in this case it doesn't, yes will just run the last "successful" build (although I haven't changed the file since I have finished it before this error message started popping up)
Also there is no error in my code as I was able to run it before the build error kept appearing and I haven't touched the file since(only now to show the problems are)
Thanks for your time! if anything was unclear because of my English, comment and I'll try to clarify it
I fixed the error by deleting ComponentModelChache folder located at:
C:\Users\%userName%\AppData\Local\Microsoft\VisualStudio\15.0
15.0 is the version of your visual studio so it varies depending on the version you're using, %userName% is a replacement for the user you're logged in as

Visual Studio "The debug worker process exited unexpectedly" on the same breakpoint every run

I'm trying to debug my vulkan code. However, I get a visual studio debugger crash if I place a hit point within this loop (code below). I'm using Visual Studio Community 2019 16.4. Things I have tried so far:
Rebuild
Clean
Repair Install
New Install
Visual Studio Preview (16.5)
I don't think it's code specific, but here's the code. If it makes a difference, it's during a vulkan command buffer record, but I really don't think it's vulkan related.
EDIT: Now exhibited same behaviour in a completely different place in my code. I have no idea what the common factor is.
for (VulkanObjectAttachment * voa : md->contents)
{
int i = 0;
for (auto x : currentPipeline->shader->shaderSpecificFeatures)
{
int setIndex = (i * HE2_RenderBackend::imageCount) + frameIndex;
vkCmdBindDescriptorSets(*commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, currentPipeline->pipelineLayout, x.first, 1, &voa->specificFeatureDescriptorSets[setIndex], 0, nullptr);
i++;
}
vkCmdDrawIndexed(*commandBuffer, static_cast<uint32_t>(vma->indices), 1, 0, 0, 0);
}
First, the busy message appears here, and you can't click anything
Then, this error message appears, about 15 seconds later
Visual Studio “The debug worker process exited unexpectedly” on the
same breakpoint every run
This problem is usually caused when you are debugging code and loading multiple instances of the same module in the application domain. To troubleshot this issue, you can try these steps:
One
1) check the option Use Managed Compatibility Mode by Tools-->options-->Debugging-->General.
Two
1) Remove all the breakpoints first by Debug-->Delete All Breakpoints.
2) close Project and then reopen VS
3) run your project first without any breakpoints and after that, put any breakpoints you want to debug your project
Hope it could help you.

Is my application runs from inside Visual Studio vs. by executing an EXE file

As I often test my binaries inside/outside Microsoft Visual Studio 2017, I want to control the behavior of my code in C/C++ console projects.
One for code for when I run .exe from within Visual Studio in Release mode.
Another when I just click my .exe from Explorer.
What flag or function should I use to know if my .exe was started from inside Visual Studio or not.
What I would like to achive is the:
#if !_RELEASE
system("pause"); // prevents auto shutdown of my .exe in Explorer
// double click
#endif
where _RELEASE is some kind of trait that triggers code in Studio launches,
but not visible in Explorer double click.
What flag or function should I use to know if my process was startded from inside Visual Studio or not.
You shouldn't do such behavior control from inside your program code. That's bad design, and clutters your program code with decisions that should be left on the caller.
I'd recommend if you need different behaviors of your program (e.g. running in background or with visible GUI), this should be controlled with e.g. configuration files or command line parameters.
You can do that for both, Visual Studio settings to specify cmd line parameters, or using a different configuration file, or even a combination of both.
As you seem to insist for a solution of your idea how to fiddle with this in the best way:
You can use the WINAPI functions to iterate through your parent process IDs and check if one of these is matching the "Visual Studio" module.
Here's a Q&A which links to the technique:
How can I reliably check whether one Windows process is the parent of another in C++?
It not exactly solution, but:
Raymond Chen(Microsoft winapi guru*) is most close in spirit to the problem I facing, helping me detect in what mode or circumstances I run my console session.
How can I tell whether my console program was launched from Explorer or from a command prompt?
printf("this process = %d\n", GetCurrentProcessId());
DWORD count = GetConsoleProcessList(nullptr, 0);
if (count == 1) {
printf("I'm the last one!\n");
Sleep(2000);
}
else {
printf("I'm not the last one! %d\n", count);
}

Cannot debug single theory in isolation

Is there a way to debug an individual theory in Visual Studio 2017? This worked in 2015. Now, in 2017, starts the debugger and kicks off all test cases in the theory.
I just updated the latest release of 2017 (15.9.7). Not sure if it worked beforehand.
I can choose an individual test, but when I click debug, they are all executed.
This works in Visual Studio 2015 (14.0.25431.01 Update 3). The issue persists in Visual Studio 2019 preview 1.1.
Shortened code sample:
namespace MyNameSpace
{
public class PayloadTest : BaseTest
{
[InlineData("AllergyDataChanged")]
[InlineData("ImplantableDeviceDataChanged")]
public void test1(string source, Type entityIdType = null)
{
TestSubscriber(source, entityIdType);
}
Go to: Tools > Options > Test > General > Uncheck "Discover tests in real time from source files"
This appears to be an issue with Visual Studio 2017+.
Source of quote is a response a received on Github

Exception thrown when exiting program (Ogre3d)

I am getting a weird exception when I exit the program. This has started since today morning and I am ready to pull my hair out. As soon as I exit the program, visual studio gives an exception and stops at line 731 in the file crt0dat.c (see attached screenshot)
I know this is very little to go on. I have tried several different things:
un the program without doing anything, that is, not initializing Ogre Core at all. Does not result in a crash
Run the program with everything commented out except creating Ogre root (which is related to Ogre itself and has nothing to do with my code), results in the same crash
Run the following program which is as basic as it gets, still results in the crash. The crash happens after return 0, when my program has finished running
#include "windows.h"
#include "OgreRoot.h"
/// --------------------------------------------
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
{
Ogre::Root* lRoot = new Ogre::Root();
delete lRoot;
lRoot = NULL;
return 0;
}
/// --------------------------------------------
Since I have everything on the SVN, I ran the same project on my laptop and it worked without any problems, as well as exited without any problems. This led me to believe that somewhere along the line my visual studio got corrupted. I uninstalled Visual studio, then re-installed it, but the problem persists (When VS installs it goes all over my system. No way to contain it. Does anyone know a surefire way to completely destroy Visual Studio installation?). I am running out of ideas, short of re-installing windows. I hope someone here can be of help.
Callstack:
048b0910()
ntdll.dll!775d9901()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!775edc30()
ntdll.dll!775edb7c()
kernel32.dll!76c67363()
> msvcr90d.dll!__crtExitProcess(int status=0) + 0x1b bytes C
msvcr90d.dll!doexit(int code=0, int quick=0, int retcaller=0) + 0x1d1 bytes C
msvcr90d.dll!exit(int code=0) + 0x12 bytes C
OgreFWGame.exe!__tmainCRTStartup() + 0x2a2 bytes C
OgreFWGame.exe!WinMainCRTStartup() + 0xf bytes C
kernel32.dll!76c63677()
ntdll.dll!775d9d42()
ntdll.dll!775d9d15()
Crash Screencapture:
link text
That is not how you are supposed to initialize and use Ogre. Most likely the missing initialization work is what causing your crash.
To get started with ogre I highly recommend following and learning from the tutorials
Edit:
visual studio project templates for ogre can be found here: http://code.google.com/p/ogreappwizards/updates/list to get started quickly.
Thanks for everybody's help on this problem. I ended up re-installing windows (I tried uninstalling Visual Studio and re-installing it, but something went wrong while uninstalling VS [I followed Microsoft's instructions to the letter] and it would refuse to install again [the setup would crash]). I wish they would make it easy to Uninstall Visual Studio.
I wasted about 3 days before I resorted to re-installing windows. My advice would be, if you have another computer to continue to do your work on, is to do the same if something like this happens rather than waste days. If you do find a way to fix the problem, please let me know :)
I recently set ogre up in Visual Studio 2010 and it refused to work right until I copied in the right DLLs - I had been using a set compiled from a slightly older version of ogre in Visual studio 2008. It sounds like the entire ogre compilation or the DLLs may have been copied over via the SVN which could cause strange problems.
Hope it helps, anyway.