Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Visual Studio

Visual Studio: Fix ‘Unable to Start Program’ After Switching Git Branches Without Reinstalling

- 30.08.26 | 31.08.26 - ErcanOPAK

🛠️ Switched Branches? Clean Before You Debug

Switching Git branches in Visual Studio and immediately hitting F5 sometimes throws “Unable to start program… The system cannot find the file specified” — even though the code builds fine. The cause is almost always stale build output, not a broken project.

🔍 Why This Happens

Git only tracks source files, not the bin/ and obj/ folders
(they're correctly gitignored). When you switch branches, if the
target framework, output path, or project references differ even
slightly between branches, Visual Studio's incremental build can
end up pointing at an exe/dll path that no longer matches what's
actually configured - or a half-updated obj/ cache confuses MSBuild
about what needs rebuilding.

✅ The Fix, in Order of Effort

  • Try the cheapest fix first: Build → Clean Solution, then Build → Rebuild Solution.
  • Still broken? Close Visual Studio and manually delete the bin/ and obj/ folders in the project directory, then reopen and rebuild.
  • Still broken after that? Check whether the branches actually target different .NET versions/SDKs — that requires more than a clean, it needs the right SDK installed.

🧹 Manual Clean (PowerShell, run from solution root)

Get-ChildItem .\ -Include bin,obj -Recurse | Remove-Item -Recurse -Force

# Then in Visual Studio:
# Build -> Rebuild Solution
# Debug -> Start Debugging (F5)

⚠️ Make This Automatic Going Forward

  • Visual Studio has no built-in “auto-clean on branch switch” — but you can add a simple pre-build check or just make Clean-before-Rebuild a habit after any branch switch that touches project files (.csproj).
  • If you use Git hooks, a post-checkout hook that deletes bin/obj can automate this project-wide.

“Unable to start program” right after a branch switch is Visual Studio pointing at a file path that no longer matches reality — Clean + Rebuild fixes that mismatch faster than any deeper troubleshooting.

— Developer Tip

Related posts:

Visual Studio Uses More CPU When Idle Than Expected

Visual Studio Uses More CPU When Idle Than Expected

Visual Studio Uses Too Much RAM Even with Small Projects

Visual Studio Uses Too Much RAM Even with Small Projects

Visual Studio: Fix the Diagnostic Tools Memory Usage Graph Flatlining at Zero Because the Session Lo...

Visual Studio: Fix the Diagnostic Tools Memory Usage Graph Flatlining at Zero Because the Session Lo...

Views: 32

Post navigation

SQL Server: Recover an Accidental UPDATE Without WHERE Using the Transaction Log
SQL Server: Why NOLOCK Silently Returns Duplicate or Missing Rows

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (661)
  • Add Constraint to SQL Table to ensure email contains @ (619)
  • Average of all values in a column that are not zero in SQL (577)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (553)
  • Find numbers with more than two decimal places in SQL (481)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store
  • WordPress: Fix a Navigation Block Losing Submenu Items After Sync
  • Visual Studio: Fix CodeLens Reference Counts Stuck at Stale Numbers
  • C#: Fix a UTF-8 String Literal Behaving Differently in a Switch
  • Photoshop: Fix a Liquify Mesh Snapping Back on a Smart Object
  • The AI Prompt That Turns a Crash Dump Into a Short Repro Script

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com