How can I disable javascript compile warnings in VS 2010? - visual-studio-2010

Visual studio seems intent that my javascript code is bad, mostly because it has no knowledge of jquery or some plugins I am using. Therefore, every time I compile my product it gives me a lot of warnings, most of them are incorrect ($ is not defined, window is not defined, etc...).
I have /// <reference path="" /> tags setup in my javascript with intellisense working properly so I know these are just not real issues.
How can I disable these warnings?
edit to be clear, I need these disabled because it's causing 100+ warnings that are making me lose sight of REAL c# warnings.

I had the exact same issue you were having: 100s of incorrect errors every save. For me the issue was with Chirpy, which was a prerequisite for another extension. For whatever reason on my end, Chirpy was not in my Extension Manager so it took me a while to find.
Check and see if you have it installed. If so disable JSHint.
Tool -> Options
Chirpy -> JSHint
Uncheck: Run JS Hint

try this and let me know if it works.
Enter the options through Tools > Options.
In the tree to the left, choose Text Editor > JScript > Miscellaneous. Uncheck "Show syntax errors".

I don't have a javascript source file on the computer I'm on at the moment to test this, but you may be able to use the #pragma command to disable particular warnings:
#pragma warning disable will disable all warnings, and #pragma warning restore will restore all warnings when placed at the end of your code block. You can also tell it to disable only particular warnings, such as #pragma warning disable 0219,0168.
http://abhijitjana.net/2010/08/27/how-to-suppress-complier-warning-using-pragma-warning-directives-in-visual-studio/

Interesting I am not able to reproduce your issue in neither VS2010 "website" project nor vs2010 "web application" project. It has to do with the add-ons that you installed. Probably you may have a setting in that add-on (who ever is causing this) to disable warnings.
To me the warning sounds like the add-on (who ever is causing this) is not intelligent enough. Try the below changes and see if that helps.
If you have master page then try move the jquery*.js script reference from master page to your actual page
Move all your javascript code into a js file instead of writing it them under script tag
Thanks,
Esen

What about this one?
To disable a single compiler warning
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Compile tab.
In the Warning configurations table, set the Notification value for the warning to None.
or perhaps this one
Tools > Options > Text Editor > JScript > Misc > Show errors as warnings( uncheck only this )

Related

Disable HTML element tooltips in Visual Studio

I was wondering if anyone has had any luck disabling the HTML element tooltips in Visual Studio 2015. I find them to be a real annoyance, especially when dragging/ctrl+dragging text around (they get in the way most the time). Here's a screenshot the feature in action (updated):
I Googled and was only able to find the post where the feature was announced, but no mentions of how to disable it. I checked my Visual Studio preferences and have "Auto list members" and "Parameter information" disabled for the HTML text editor.
Any ideas or suggestions?
Update (10/16/2015): I think this issue may be related to the Web Essentials package. I disabled the package and was able to make the tooltip show up, however, I don't currently have a computer with a default Visual Studio 2015 install to test my theory on. I updated the screenshot to reflect the actual tooltip I'm getting (the original one was the screenshot included in the linked blog post).
Try this:
Go to: Tools > Options... > Text Editor > HTML > General
In the 'Statement completion' section you will see an 'Auto list members' checkbox, uncheck it.
However, I'm not sure if the feature above reffers to an in-design html editing or will only affect in specific html development environment (editing an html file for example), so I'll give an additional solution:
Go to: Tools > Options... > Environment > Keayboard
Here, find the command Edit.ToggleCompletionMode and assign the keyboard shortcut that you desire.
Then just use it when you wish to toggle the auto completion of members (including html members I supose).
Update
Sorry If I confussed what you want, because with the absence of auto completion it will remove existance of tooltips but I don't know if you need auto completion suggestions or not.
Anyways, for tooltips you could try doing the same procedure I explained in the images above but with the "Parameter Information" checkbox and/or the corresponding keyboard shortcut, Edit.ParameterInfo. Because seems that html element tooltips are treated as parameter info.
This was annoying the Hell out of me as well & I found that ElektroStudios' solution wasn't suitable in my case. I'm fairly sure that they are VS-native (definitely not Web-Essentials or ReSharper).
For VS2015 at least, the offending tool-tips are located within the file:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Schemas\1033\HTML\html.loc
Deleting the contents of this file has "disabled" the tool-tips for me, although I can't say whether this will be a permanent fix.

Putting Resharper's ignored errors under version control

When I ignore specific errors in "Errors in Solution" window, Resharper remembers this setting.
I tried to reboot and restart Visual Studio, the ignored errors stayed ignored. Now I wanted to pass the ignored errors list to another programmers in the team by putting some setting file under version control. But I could not find where does Resharper store which errors are ignored.
I have the following versions of SW.
Visual Studio 2012
JetBrains ReSharper 8.2.1 Full Edition
Build 8.2.1000.4556 on 2014-05-19T10:12:38
Update:
I removed files in the following folder and the ignored errors reset, all errors became unignored.
%AppData%\..\Local\JetBrains\ReSharper\v8.2\SolutionCaches\
So it keeps the ignored errors somewhere in those files. Still I did not see the way to put it under version control.
Though not related to the exact issue of the original poster, you might have stumbled upon this question looking for the answer below :)
If you've changed the behavior of an inspection from the glyph like this and saved it to a configuration layer and set it to Do Not Show or something else and then saved it to the Team level:
Then depending on where you set the value, Computer, Solution personal or Solution Team, it's stored in a different settings file.
You can then add the Solution.sln.DotSettings file to source control to share these suppression between all team members.
To undo the supression of such warnings, you'll have to venture into the layered options structure of Resharper, which can be a little confusing if you haven't gone in there before.
Then depending on where it's saved, look under the wrench item for the selected layer:
Find the inspection and set it:
In the toolbar to the solution errors window, there should be an export button. You should be able to export all ignored items to xml or html here.

Is it possible to disable specific compiler warnings?

I am trying to suppress specific compiler warnings, namely System.Data.OracleClient.OracleConnection' is obsolete. I came upon these questions here:
How to disable specific warnings for the entire solution?
Globally suppress c# compiler warnings
...but they don't seem to apply to VS2013. When I go to my project's properties, I don't see a Build tab. I see a Compile tab, but it doesn't appear to have a place to specify warning messages to suppress. I see a section there called Warning configurations, but I don't see the warning I am looking for.
Update: It turns out that I am trying to do this for VB.NET. Thanks to a link provided by the selected answer, you have to edit the project file's XML and supply the warning code in the <NoWarn></NoWarn> tag. However, you have to know the warning code which is hidden in the error list. One way to get it is to open the output window and build the project. In my case, the warnign code is 40000. It shows as BC40000, but I had to remove the BC. After rebuilding the project, the warning messages went away.
To suppress specific warnings for Visual C# or F#:
In Solution Explorer, choose the project in which you want to suppress warnings.
On the menu bar, choose View, Property Pages.
Choose the Build page.
In the Suppress warnings box, specify the error codes of the warnings that you want to suppress, separated by semicolons, and then rebuild the solution.
Check out here for more info on how to suppress specific warning for Visual C++ and Visual Basic.
Another ways is to use #pragma warning can enable or disable certain warnings.:
#pragma warning disable warning-list
#pragma warning restore warning-list
warning-list
A comma-separated list of warning numbers. Enter the numbers alone, without the "CS" prefix.
When no warning numbers are specified, disable disables all warnings and restore enables all warnings.
Yes, it is possible.
#pragma warning disable 'warning-number-list'
where warning-number-list is a comma separated list of warning numbers to disable, e.g. 1004
This will disable the warning from its point of declaration to the end of the current file unless re-enable with:
#pragma warning restore 'warning-number-list'.
These pragmas are placed inline in your code at the site of where you wish to disable/restore the warnings.
I believe there is also a place on the Project properties tabs to specify warnings to disable, as you mentioned.

Why doesn't VS2010 debugger stop at my breakpoints?

I am working on a C#.NET class library project in VS2010. In my project settings -> debug settings, I have the project set to start an external program (C:\Windows\SysWOW64\wscript.exe) which runs a very simple jscript file (test.js). The script simply creates an instance of the class and calls one of it's methods.
The problem is when I start debugging, VS2010 does not stop at any of my breakpoints. If I open up the exact same project in VS2008 it does stop at the break points. Is there a new setting somewhere that is preventing the breakpoints from being hit? Has anyone else ran into this issue?
My first check would be to disable "Just My Code"
Tools -> Options
Debugger
Uncheck "Enable Just My Code"
Try the scenario again.
To solved this problem by creating a config file for the application which is using the component to debug with the following data:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
With this file you tell the debugger to use the right runtime version for debugging (it seems the debugger uses version 4.0 by default).
I have a tried a whole day to find out why I couldn't debug my visual studio 2012 console application, and the answer was embarrassing.
I was running it in "RELEASE" mode.
Sometimes the obvious is the hard to find.
Close the Visual Studio IDE and Open it. Now it will work. For me it also face the same issue. I used this way to overcome
I had a "Rebuilt" VS2013 project that I couldn't debug (no symbols). Finally, I saw Optimization was checked (Project->Properties->Build). I unchecked it and Rebuilt. Symbols loaded finally. My two cents, only use (compile) Optimization when absolutely necessary.
While I can't answer why it happens, I can provide you with workaround.
Include
using System.Diagnostics;
At the very beginning of your code (Class constructor for instance) place the following lines:
#if (DEBUG)
while(!Debugger.IsAttached);
Debugger.Break();
#endif
Start debugging.
Menu Tools→Attach to Process
Attach to your process.
breakpoint should trigger in your code.
Other breakpoints should trigger as well.
Could be a number of reasons. Usually it's because you're trying to debug against the wrong version.
These actions work about 80% of the time.
Get the latest code
Clean
Rebuild
Restart IIS
Try again
If no good, go to Debug > Windows > Modules and if the relevant dll is there, right click it and load symbols.
If it's not in the list, try running the code anyway. Sometimes even though it says the breakpoint will not be hit, it's only because the dll is not loaded until you enter a scenario that needs it. Try the scenario that depends on the dll, and it may just hit the breakpoint anyway.
Oh one more idea, restart your browser. You might have something cached from an older dll.
If the reason is wrong .NET runtime version (which was my problem), instead of creating configuration file you can simply choose the right version in the Attach to process dialog.
In the dialog, next to Attach to click on Select and switch from Automatically... to Debug these code types where you should check the right version.
If this was your problem also, then you probably had "Symbols not loaded" message on your breakpoints. Immediately after selecting the right version you should see that this error is no longer reported.
For me it was fixed by:
Open the project properties is VS2010
Goto Compile -> Advanced Compile Options
Change 'Generate debug Info' from 'None' to 'Full'
The problem could be your browser is using a cached version of the page, you are working with.
Try to add som nonsense extra querystring in your adress line of the browser f.x. add ?NONSENSE=1234
This forces the browser to use a new version of the web page since it does not know if the page should look different with this Query in the end. Next time use ?NONSENS=1235.
I had a problem with misplaced breakpoints in my native c++ code.
The reason was I had been editing the code so some line ends in the code was not \r\n. It was not possible to see in the code unless you searched for \r\n.
After inserting the proper line ends \r\n the debugger worked.
I encountered the similar issue but its in a CLR project. I had some old c++ syntax in the CLR project. For me after I enabled 'Use managed compatibility mode' in Tools>options>Debugging>General it started to hit the break points.

Edit and Continue: "Changes are not allowed when..."

Even if I create a clean WinForms project, Edit and Continue doesn't work and gives me the error:
Changes are not allowed when the debugger has been attached to an already running process or the code being debugged was optimized at build or run time.
Edit and Continue option is checked in Tools → Options → Debugging.
Optimization is not enabled.
Seems like there is no any managed profiler set up.
I am running in Debug mode
I am running on x64 CPU and Windows XP 32-bit, but setting platform target to x86 rather than AnyCpu doesn't help.
Repairing Visual Studio installation doesn't help.
I also found this article on MSDN website:
Unsupported Scenarios
Edit and Continue is not available in the following debugging scenarios:
Debugging on Windows 98.
Mixed-mode (native/managed) debugging.
SQL debugging.
Debugging a Dr. Watson dump.
Editing code after an unhandled exception, when the "Unwind the call stack on unhandled exceptions" option is not selected.
Debugging an embedded runtime application.
Debugging an application with Attach to rather than running the application with Start from the Debug menu.
Debugging optimized code.
Debugging managed code when the target is a 64-bit application. If you want to use Edit and Continue, you must set the target to x86. (Project Properties, Compile tab, Advanced Compiler setting.).
Debugging an old version of your code after a new version failed to build due to build errors.
But I can answer "No" to every item in this list.
It worked before, but several days ago it stopped working, and I don't know what could be the reason.
Other Applicable Solutions:
Below is an incomplete, unordered list of possible solutions to try if you* are trying to fix Edit & Continue quickly.
Make sure you are in Debug Mode
Make sure you're not launching a mixed mode process
Try to set the CPU target to x86 rather than AnyCPU (on x64 machines)
Uncheck the Optimize Code checkbox for Debug Mode in Project Properties->Debug
Uncheck the Optimize Code checkbox in Project Properties->Build
Uncheck Enable Optimizations in Advanced Compiler Settings
(ASP.NET) Check nightcoder's answer if it is the case
(ASP.NET) Check this answer (by matrixugly) if it is the case
(ASP.NET) Ensure you have Edit and Continue enabled on the Web tab (vs2010)
(ASP.NET) Go to Properties > Web > Servers, and make sure that Enable and continue is checked under Use Visual Studio Development Server.
(ASP.NET WebAPI) Make sure you've stopped in the Controller's method using a breakpoint, before trying to edit it.
(vs2017) Go to Tools > Options > Debugging and uncheck (deselect) 'Edit and Continue'. This is actually the opposite of the 'conventional' advice (see some other points in this post). It does not allow you to actually make changes in your running program (i.e. it does not hot-swap the code changes that you make) - it simply allows you to edit your code (i.e. it prevents that annoying message and "locking" your editor).
Go to Tools > Options > Debugging > General and make sure Require source files to exactly match the original version is unchecked.
Check Enable Windows debug heap allocator (Native only) [VS Community 2017]
Are you using Microsoft Fakes? It inhibits Edit & Continue.
Kill all the *.vshost.exe instances by selecting End Process Tree in the Task Manager. VS will regenerate a correct instance.
Remove all the breakpoints with Debug->Delete All Breakpoints
Enable and Continue exists in both the Tools > Options > Debugging menu and also in the Project Settings. Be sure to check both places. edit & Continue is not supported with the extended Intellitrace setting.
Be sure Debug Info in Project Properties > Build > Advanced > Output > Debug Info is set to Full
Some plugin may be interfering. Check by disabling/uninstalling and then trying again the other solutions.
If you're not paying enough attention, the error you get while trying to fix this may change to something else that is easier to diagnose. E.g. A method containing a lambda expression cannot support edit and continue.
Make sure the System variable COR_ENABLE_PROFILING is not set to 1. Some profilers set this when installing and leave it like that after uninstalling. Open a command prompt and type set to quickly check it your system is affected, if so remove the variable or set it to 0:
In Windows 8 and above, search for System (Control Panel).
Click the Advanced system settings link.
Click Environment Variables.
Remove COR_ENABLE_PROFILING
Be aware of unsupported scenarios (as reported in the question) and that unsupported edits.
* by 'you', I mean the visitor of the page who is hammering his head on a keyboard to find The solution.
Feel free to edit this answer to add your workaround if not listed here!
If you're debugging an ASP.NET application, go to properties > web > Servers, and make sure that "enable and continue" is checked under Use Visual Studio Development Server.
I finally got to solve the problem: UNINSTALL Gallio
Gallio seems to have quite some many rough edges and it's better to not use MbUnit 3.0 but use the MbUnit 2.0 framework but use the gallio runner, that you are running without installing from the installer (which also installed a visual studio plugin).
Incidentally, I had the issue even after "disabling" he Gallio plugin. Only the uninstall solved the problem.
PS. Edited by nightcoder:
In my case disabling TypeMock Isolator (mocking framework) finally helped! Edit & Continue now works!!!
Here is the answer from TypeMock support:
After looking further into the edit
and continue issue, and conversing
about it with Microsoft, we reached
the conclusion it cannot be resolved
for Isolator. Isolator implements a
CLR profiler, and according to our
research, once a CLR profiler is
enabled and attached, edit and
continue is automatically disabled.
I'm sorry to say this is no longer
considered a bug, but rather a
limitation of Isolator.
I had the same problem. I even re-installed VS 2008 but the problem did not go away. However, when I deleted all the break points then it started to work.
Debug->Delete All Breakpoints
I think it was happening because I had deleted an aspx page that had break points in its code, and then I created another page with the same name. This probably confused the VS 2008.
"Edit and Continue", when enabled, will only allow you to edit code when it is in break-mode: e.g. by having the execution paused by an exception or by hitting a breakpoint.
This implies you can't edit the code when the execution isn't paused! When it comes to debugging (ASP.NET) web projects, this is very unintuitive, as you would often want to make changes between requests. At this time, the code your (probably) debugging isn't running, but it isn't paused either!
To solve this, you can click "Break all" (or press Ctrl+Alt+Break). Alternatively, set a breakpoint somewhere (e.g. in your Page_Load event), then reload the page so the execution pauses when it hits the breakpoint, and now you can edit code. Even code in .cs files.
Couple of things to check
Make sure your compile is set to Debug vs. Release
Make sure you're not launching a mixed mode process
If on a 64 bit machine Make sure to set the CPU target to x86 rather than AnyCPU
EDIT
I don't believe this should matter but make sure that the hosting process is enabled for the target platform. Probably won't help.
If it repros for new projects then it might be something even more subtle. I would try the following.
Backup HKCU:\Software\Wow6432Node\VisualStudio\9.0 (maybe just rename it)
Delete the same key
Try the repro again
None of the above solutions worked for me(running on a 64x machine).
Finally I clicked on 'advanced compiler settings' and UNCHECKED 'enable optimizations' and I can now step through code and edit while debugging.
For me, for a reason that I don't understand, the setting "Generate debug info" in the "Advanced Compiler Settings" was set to "pdb-only" instead of "Full".
By default, this parameter is always set to "Full" but a mysterious poltergeist has changed this parameter on last night. :)
P.S. I'm in Visual Basic .Net with Visual Studio 2010
If your concern is with an ASP.NET app, ensure you have edit and continue enabled on the web tab (vs2010). There was also a separate setting for ASP.NET debugging in earlier versions.
Regards,
Adam.
I found that even though under project properties build & debug tab are set to Debug and all the other setting are correct I still get the message, however after digging some more
under the Build menu select Configurations Manager... and make sure Debug is selected in two places there as well. go figure...how many different places do they need to set debug?????? even though you set Project - Configuration to Debug then under Build - Manager it is not changed so you have change the same setting there as well Project Configuration - seems like a microsoft issue again.......
This problem is due to Intellitrace setting
If Intellitrace is enabled make sure Intellitrace event only is checked
Otherwise this will not allow edit and continue..
If you will click on Intellitrace options you will see the warnings.
Following shooting helped me using VS2010:
go to Tools, Options, Debugging, General and make sure "Require source files to exactly match the original version" is unchecked.
That happens when the debugger hasn't hit a breakpoint or you haven't hit Break All (pause). It couldn't be that simple could it?
The error says a possible cause is: "the code being debugged was optimized at build or run time". Go to Project Properties->Debug and uncheck the Optimize Code box for Debug mode.
I had this problem in Microsoft Visual Studio 2008 and the solution is easy. when you run your project please set in "Debug" mode not "Release". The another people solution can be useful.
If I create a new project, edits while debugging do not work. If I create a new website, edits while debugging work as expected.
I ran into this today - turns out that having Debug Info set to pdb-only (or none, I'd imagine) will prevent Edit and Continue from working.
Make sure your Debug Info is set to "full" first!
Project Properties > Build > Advanced > Output > Debug Info
In my case just reseting to default debugger settings and setting IntelliTrace-> only intellytrace events helps
Some things that seemed to help using VS2010:
go to Tools, Options, Debugging, General and make sure "Require source files to exactly match the original version" is unchecked.
multiple .vshost.exe instances can be left over from e.g. detaching the VS debugger from a stopped process. This will interfere with breakpoints and compiles as well. Use Task Manager, Processes tab to kill all instances of .vshost.exe by right-clicking each instance and selecting End Process Tree. VS will create a new instance.
I removed a dataset from my project because I didn't use it. After that I could modify the program when debugging.
I did all the changes mentioned in every other answer and none worked. What did I learn? Enable and Continue exists in both the Tools > Options > Debugging menu and also in the Project settings. After I checked both, Enable and Continue worked for me.
Seems illogic, but only way was disabling edit and continue from VS 2017 options... Then AspNet edit and continue began to work...
what worked for me was unchecking "Use Managed Compatibility Mode" under
Tools -> Options -> Debugging
TBN: checking or unchecking "Require source file to exactly match the original version" seems not influences the E&C
Hope this can help.
Enable edit and Continue only work run IIS Express.
Don't work in Local ISS or External Host.
I'm adding my answer because the thing that solved it for me isn't clearly mentioned yet. Actually what helped me was this article:
http://www.rubencanton.com/blog/2012/02/how-to-fix-error-changes-are-not-allowed-while-code-is-running-in-net.html
and here is a short description of the solution:
Stop running your app.
Go to Tools > Options > Debugging > Edit and Continue
Disable “Enable Edit and Continue”
Note how counter-intuitive this is: I had to disable (uncheck) "Enable Edit and Continue".
This will then allow you to change code in your editor without getting that message "Changes are not allowed while code is running".
Note however that the code changes you make will NOT be reflected in your running program - for that you need to stop and restart your program (off the top of my head I think that template/ASPX changes do get reflected, but not VB/C# changes, i.e. "code behind" code).
I install the stackify, when i enable this on icon tray, it stop my debugging with edit, so i found
Close the visual studio , in my case its vs2017
Go to icon tray and right click on stackify icon and disable .NET Profiler
Open Visual studio run application again in debug mode with debugger and it allow me edit while debugging
I had this annoying issue since I upgraded my VS 2019 to 16.4.3 and caused me a lot of headache.
Finally I solved the problem this way:
1. Stop Debugging
2. Select the solution from "Solution Explorer"
3. In the Properties window change the "Active config" Property From "Release|Any CPU" To "Debug|Any CPU"
4. In Debug > Options > General Check the Edit and Continue checkbox
That worked for me, and hope it works for you too.
embed interop types visual studio should be set to false
I had this happen in a linked class file. The rest of the project allowed E&C, but I got the same error editing the linked file. Solution was to break linked file into it's own project and reference the project.
I faced the same problem. My problem was that I could modify a file, but not another (both are in same project). Later I found that the file I couldn't modify was also part of another project. That another project (Unit Test) wasn't loaded, and intelligent VS debugger shows the error that assembly for this given file was not loaded, and changes aren't allowed. How weird!
Hence, I had to unload the unit-test project and continue the EnC debugging.

Resources