Using a Visual Studio props files

When you want multiple projects in a solution to use the same project settings (some or all), you can put the settings in a shared props file. There are two options: I’ll show both options below. Note: You can also use a combination of these two options. Option 1 – Use Directory.Build.props You can use … Read more

Error MSB4226 Microsoft.TextTemplating.targets not imported

Problem You have a project that is using text templating (such as for auto-incrementing the version number) and you’re upgrading to a new version of Visual Studio. When you open the project, you get error messages about not being able to import the Microsoft.TextTemplating.targets project: Project “…\v16.0\TextTemplating\Microsoft.TextTemplating.targets” was not imported by “…SomeProject.csproj” at (7,3), due … Read more

How to enable the built-in .NET Analyzers

Previously you had to install and enable .NET Analyzers if you wanted to use it. Now, when you create a new project, it’s already installed and enabled by default (but you may want to change its settings). There are two main scenarios: If .NET Analyzers is already installed When you create a new project targeting … Read more

How to generate XML documentation and include it in a nuget package

XML documentation comments serve two purposes: In this article I’ll show how to automatically generate an XML documentation file and how to include it in a nuget package. 1 – Write the XML documentation comments in your code I have a method called MergeInPlace() (which merges two dictionaries in-place). To explain what this is doing … Read more

Class Diagrams missing in Visual Studio

Problem The Class Diagram item is missing in Visual Studio. Note: I ran into problem starting in VS2019. Solution For some reason this is not installed by default in Visual Studio, so we simply need to install it. 1. In Visual Studio click Tools > Get Tools and Features… 2. Close Visual Studio. 3. In … Read more

The referenced component could not be found

Problem When I open a C# project in Visual Studio, none of the references are loading. In the error list it says “The referenced component could not be found” for several references. Here’s a snippet showing just a few of the reference errors: The referenced component ‘System’ could not be found.The referenced component ‘Microsoft.CSharp’ could … Read more

Auto-increment build numbers in Visual Studio

You need to auto-increment your build numbers in order to easily tell which code you’re working with. In this article I’ll explain how to auto-increment your build numbers in Visual Studio. I’ll be using text templating to generate the Assembly Version. 1 – Choose a versioning scheme I’m going to be using the version scheme: … Read more

ReportViewer doesn’t appear in the toolbox in Visual Studio

Problem You’re trying to use the ReportViewer control in Visual Studio but it’s not in the toolbox. Other symptoms: Solution Note: Tested in Visual Studio 2017 and Visual Studio 2019. The exact instructions may have slightly different steps depending on which version of VS you’re using. There are two different problems to solve. First, you … Read more