Most of the time when we try to run a simple Visual Studio Windows Forms App (.NET framework) project build, we end up with the error: ‘C:\users\username\source\repos\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe’ - Access is denied. On a rare occasion the program will run properly without the error, but most of the time when students and teachers are trying to run their projects they fail with the access denied error. We are running Visual Studio 2022 Community on Windows 11 desktops in a Hybrid AD environment.
As suggested by the MSFT member who was assisting me, I added the source folder to the Excluded Folders in Windows Defender Threat Protection through Group Policy, but it made no difference.
Can you check if there are any logs around the time the application was blocked? They are available in the "Applications and Services Logs/Microsoft/Windows/Windows Defender/Operational" folder in Event Viewer locally on the device.
All block events should present as warnings or errors.
If you have Defender for Endpoint, blocks should show up in the Action Center of Microsoft 365 Defender as well.