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
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 Share on XTo Problem B:
- Right click on whole solution
- Click Restore Nuget Packages
- Rebuild solution
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.
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
- Follow the instructions here to get to the Modify screen of Visual Studio
- You might be prompted to update VS Installer, go ahead and do so
- 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.
- Click the Modify button
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 Share on XUnhandled 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’ …
Error Message
This message is in your Output pane in “Output from Tests”.
An exception occurred while invoking executor ‘executor://mstestadapter/v2’: Constructor on type ‘Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner’ not found.
The Symptoms
You are trying to run your Automation tests using MSTest, but they don’t run. They start going, but then Visual Studio just stops. When you check the Output pane, you see the message described above.
MSTest has a bug and needs an update. I had version 1.1.11 installed and it caused me this issue.
The Solution
- Using NuGet Package manager, update your MSTest.TestAdapter and MSTest.TestFramework NuGet packages to the latest version. I updated to 1.1.18.
- Restart Visual Studio
- Re-run your automation tests
An exception occurred while test discoverer ‘NUnit3TestDiscoverer’ was loading tests…
Error Message
An exception occurred while test discoverer ‘NUnit3TestDiscoverer’ was loading tests. Exception: Could not load file or assembly ‘nunit.engine’
The Problem
A caching issue with NUnit
The Solution
In this bug to NUnit, lorenh provides the solution about how to delete your cache.
An exception occurred
System.SecurityExceptions (multiple options)
Error Message
Almost any error message that contains SecurityException or something being “Inaccessible”
Here is a specific example that deals with NLog:
Error Error initializing target ‘EventLog Target[eventlog_wrapped]’. Exception: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate)
at System.Diagnostics.EventLog._InternalLogNameFromSourceName(String source, String machineName)
at System.Diagnostics.EventLog.LogNameFromSourceName(String source, String machineName)
at NLog.Targets.EventLogTarget.InitializeTarget()
at NLog.Targets.Target.Initialize(LoggingConfiguration configuration)
The Zone of the assembly that failed was:
MyComputer
The Problem
It’s stupid if you ask me, but a certainly recurring problem…
For whatever reason, Visual Studio sometimes requires you to start it as an Administrator. I believe this is after first installation or any kind of modification to Visual Studio.
The Solution
- Right click your Visual Studio icon
- Select “Run as administrator”
- Perform whatever operation you were previously trying to perform.
- The error should now be fixed
PS. You don’t need to keep running it as Administrator after this. At least it’s a one time action.
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.
Thanks. I ran into the code 9009 error and this helped me a lot.
Really happy to hear that
Constantly getting an error :
(Message:
Test method automationPart2.UnitTest1.TestMethod1 threw exception:
OpenQA.Selenium.WebDriverException: unknown error: cannot find Chrome binary)
Please help
Hi Vinisha,
The error means that it cannot find Chrome (the actual browser) in the default location. If you are using it from a different location, you need to have this in your code:
var options = new OpenQA.Selenium.Chrome.ChromeOptions();
options.BinaryLocation = @”
I can’t get past lesson 31. Unit rest project. I try to run the test via right clicking on the TestMethod1 and I get the following error:
Project ‘..\ClassLibraryPractice\ClassLibraryPractice.csproj’ targets ‘netcoreapp3.1’. It cannot be referenced by a project that targets ‘.NETFramework,Version=v4.7.2’.
I have downloaded/modified the latest VS twice (which for me is Enterprise 2019 Version 4.8.04084), making sure I had all of the items similar to the ones visible in the comment above for the error “The reference assemblies for framework “.NETFramework,Version=v4.6.1” were not found…” (which was the first error I was getting).
I am not seeing any options to download the .Net Core development tools shown above when I modify VS.
Thanks in advance for your help!
Hi Laura,
You can download and install the .Net framework from the Microsoft website: https://dotnet.microsoft.com/download/dotnet-framework/net461 . This should solve your problem.
Andreea
Getting this error while trying to create reference of the ClassLibraryTest class with ClassLibraryPractice
Severity Code Description Project File Line Suppression State
Error Project ‘..\ClassLibraryPractice\ClassLibraryPractice.csproj’ targets ‘net5.0’. It cannot be referenced by a project that targets ‘.NETFramework,Version=v4.7.2’. ClassLibraryTest3
Hi Antriksh,
You cannot reference .NET Core libraries from .NET Framework, or .NET Framework libraries from .NET Core
To share code between, the libraries you have to use .NET Standard libraries, or use .NET Core/.NET framework in both projects.
Hello, I figured out the problem I was having yesterday! I think the options in Visual Studio have changed so much when creating projects that it is confusing to someone trying to follow along with a slightly older version of VS in the course. I was not choosing the .Net-specific versions for my projects. I was choosing the .Net or Core version, which was causing a problem. No need to get back to me. 🙂
I always run VS as an admin so the solution for System.SecurityExceptions (multiple options). Does anyone have other solutions? I think this happened after my windows password was changed.
Hi,I am getting this issue.Please let me kno How to resolve
Severity Code Description Project File Line Suppression State
Error This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props. AdvancedOO C:\Users\Admin\Downloads\CSharpLesons-master\CSharpLesons-master\Section11\AdvancedOO.csproj 76
I have VS Community 2022. I cloned a Project from the Github. It builds with lots of errors related to .net Framework 4.6.2.
My Installer has all the .net Framework components but doesn’t show me .net Core options to select. I can find Core under individual Components but they marked as OUT of Support. Do I still have to install them?
Hello, I get this error while i run the test case.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)
Only Test Accounts can be used with this method.