Visual Studio errors can be very annoying. Right?

Sometimes we spend hours or even days troubleshooting problems.. Ugh!

So I’ve compiled a post on the most common Visual Studio errors that my students and I encountered. I will maintain and update this post over time.

I also supplied information on how to fix these errors.

Hope it helps… 

[toc]


Visual Studio Error

The command “chmod + x” exited with code 9009

Error Message

The command “chmod + x” exited with code 9009

Command chmod + x Visual Studio error

The Problem

Problem A:

The problem is that probably occurs when you are trying to build a solution. At that point, in your console, you get this error.

This stems from the fact that you have a space somewhere in your folder structure. For example:

“C:SourceGithubFolder With Space

Problem B:

In this case, your folder structure may be fine. However, you might find a project that for some reason didn’t pull all of its dependencies from Nuget.

If you look at the solution, under References, you’ll see errors on a bunch of the Nuget packages.

The Solution

To Problem A:

Simply rename your folder or file so that it doesn’t have a space in it. For example, change the above to:

“C:SourceGithubFolderWithSpace

Your solution will now build correctly

I fixed "The command "chmod + x" exited with code 9009 error." Thanks to this post! https://ultimateqa.com/?p=8810 Click To Tweet

To Problem B:

  1. Right click on whole solution
  2. Click Restore Nuget Packages
  3. Rebuild solution
I fixed "The command "chmod + x" exited with code 9009 error." Thanks to this post! https://ultimateqa.com/?p=8810 Click To Tweet

A project with an output Type of class library cannot be started directly

Error Message

A project with an output Type of class library cannot be started directly. In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.

Project with an output type of class library
Project with an output type of class library

The Problem

The problem is that you create a project as a type “Class Library” or “Unit Test Project” and are attempting to execute this project using the key F5, which means “Run”. You cannot run these types of projects in this manner. A unit test project must be executed using the Test Explorer of Visual Studio.

The Solution

Option 1

In your IDE, go to Test > Windows > Test Explorer. This will open up the Test Explorer. Right click the name of your unit test and then select “Run Selected Tests”.

Option 2

Place the cursor inside of your test method. Press Ctrl + R, T. This will run the test that has the cursor.

This free C# course will teach you how to correctly run the different kinds of projects.


Program does not contain a static ‘Main’ method suitable for an entry point

Error Message

Program does not contain a static ‘Main’ method suitable for an entry point

The Solution

Same solution as this error “A project with an output Type of class library cannot be started directly”


The reference assemblies for framework “.NETFramework,Version=v4.6.1” were not found…

Error Message

error MSB3644: The reference assemblies for framework “.NETFramework,Version=v4.6.1” were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

The Problem

The problem is that you need to install the correct version of .NET Framework to open this solution.

The Solution

  1. Follow the instructions here to get to the Modify screen of Visual Studio
  2. You might be prompted to update VS Installer, go ahead and do so
  3. In the Installation Details pane on the right hand side, make sure that you select all of the .NET Framework and .NET Core installations. That way, your environment can support all current .NET implementations.
  4. Click the Modify button
Install all .NET environments
Install all .NET environments

Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.

Error Message

Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.

Related tech stack

Visual Studio, MsTest

The Solution

In Visual Studio go to Tools > Options > Debugging > uncheck “Enable Just My Code”


Unit tests not running in Visual Studio Test Explorer

Error message

UTA031: class … does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.

The solution

If you are using the MStest unit testing framework, make sure that your TestContext property follows the specifications listed in the message. Meaning non-static, public and must not be read-only.

It should look like this:

public TestContext TestContext { get; set; }

Unit tests not showing up in Visual Studio test explorer

Error Message

Something like this below:

…\MSTest.TestAdapter.1.2.0/build/_common/Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll

The Problem

  • Visual Studio Version: 15.0.X
  • MSTest Adapter version: 1.18

There seems to a be bug with Visual Studio and the Visual Studio test adapter when you are trying to work with the versions listed above.

The Solution

To fix this problem, you need to update Visual Studio to version 15.5.2 and your MSTest Adapter in the Nuget package manager to version 1.2.0.

Are your unit tests not showing up in the Visual Studio Test Explorer? Here is the fix https://wp.me/p7absY-4E #automation #development #programming #dotnet Click To Tweet

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly…

Error

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

The Problem

There seems to be some issue with .NET Core apps that you can learn more about here. Only if you want to read about it.

The solution

The solution I got from that post I mentioned. However, you basically just need to do this on your .NET Core project:

Install Nuget package for System.Configuration.ConfigurationManager

That should do it 🙂


An exception occurred while invoking executor ‘executor://mstestadapter/v2’ …

The Error

An exception occurred while invoking executor ‘executor://mstestadapter/v2’: Could not load type ‘Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities.SuspendCodeCoverage’ from assembly ‘Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.

The Problem

When you try to execute your test automation, you get the error below in the Output tab and no tests actually execute.

The Solution

Simply rebuild the solution and then the problem should be fixed.

Summary

Hope this was helpful?

Is there an error that you need help resolving? Please comment below and I’ll try to resolve it for you.

1 Shares
Tweet1
Share
Email
Share
Share