Issue with Visual Studio 2022 Intellisense Complete Word function? - c#

Create an ASP.NET Core project. I created it using the new Empty template using .NET 6 but it shouldn't matter. I then compiled the app.
In program.cs, locate the line where the builder object is instatiated. Add it if it is not found.
var builder = WebApplication.CreateBuilder(args);
After the above added line, type the incomplete following line of code and then, with your cursor at end of the unfinished line, click the shortcut control + space to execute the menu command Edit->Intellisense->Complete Word
builder.Services.AddS
I expected the intellisense to pop up and pre-select "AddScoped" in the list. But it just sat there.
Intellise generally works but not always. This is one example where it doesn't, at least for me.
Does it work for you? Should it work as I described? I'm thinking so...
I'm using the following version if VS:
Microsoft Visual Studio Professional 2022
Version 17.4.0
VisualStudio.17.Release/17.4.0+33103.184

I was having the same issue. Used Visual Studio Installer and executed a 'repair'. Everything works now!

Related

How to fix Visual Studio C# Project Properties not showing?

When I try to open ANY c#(also new project created at the moment), I can't view its properties.
I got this error(translated):
An error occurred while trying to load project properties window.
Close the window and retry.
The value cannot be null.
Parameter name: val
I tried to restore vs, also tried this method: https://social.msdn.microsoft.com/Forums/azure/en-US/3fb200e0-14cf-4684-bb7f-71b7808a1f83/project-not-loading-properly?forum=visualstudiogeneral
But none of those worked..
Solved by UPDATING (not restoring/repairing) Visual Studio to last build.
That doesn't make any sense by the way: like 2 months ago this version worked too(incl. project properties page).
I guess when Microsoft releases updates it forces you somehow to update its softwares.

Cannot run Roslyn Samples under VS2015 CTP 3

I downloaded Roslyn code and built it successfully within VS2014 CTP 3. I am trying to run the samples that came with the source as part of Samples.sln solution. I can build Samples.sln successfully.
I try running ImplementNotifyPropertyChangedCS sample - I made the project the startup project within the solution and pressed "Start Debugging" menu item. As a result I am getting another VS2014 instance. I open a new project within that instance, create a property and try to refactor the property. I am not getting the option to Implement Notify Property Changed refactoring.
I checked the dependencies of the new instance of the visual studio - it does not depend on ImplementNotifyPropertyChangedCS.dll file. I looked at the output window of the first devenv instance - it seems like that ImplementNotifyPropertyChangedCS.dll was loaded but later was unloaded.
Please help.

Microsoft Visual Studio 2012 cannot set breakpoint in c# file

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

Visual Studio Extensibility Package not looking at correct project

I have created a new VS 2010 extensibility package. So far, all I want to do is have the user press a button and fill a listview with the entire contents of the solution. I have the following code:
EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.
GetActiveObject("VisualStudio.DTE.10.0");
foreach (Project project in dte.Solution.Projects)
{
foreach(ProjectItem pi in project.ProjectItems)
{
listView1.Items.Add(pi.Name.ToString());
}
}
This does seem to work, however, it populates the list with the contents of the solution with the package in it and not the experimental instance that is launched when this is run. Am I instantiating the reference wrongly?
GetActiveObject method returns first process instance of DTE, not
caller DTE. (in Visual Studio SDK 2010 project on Visual Studio 2010,
type F5 to execure experimental hive may fail)
Look at here and here for more details...
No - you need to use ProjectItem.SubProject to get to what you want... depending on the solution structure some recursion could be needed... for some sample code doing nicely all this see http://www.wwwlicious.com/2011/03/envdte-getting-all-projects.html

VS2010 - How to automatically stop compile on first compile error

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!

Categories

Resources