Skip to content

Unable to debug in VS Code in macOS #1837

Closed

Description

@fingers10

Tool

Visual Studio extension

Description

I'm trying to debug a simple nanoframework program using vscode in macos and I get the below error

[NanoRuntime] Starting debug session for /Users/xxxx/Projects/xxxx/hackathon/mantis/mantis/bin/Debug
[NanoBridge] Starting bridge process: /Users/xxxx/.vscode-insiders/extensions/nanoframework.vscode-nanoframework-1.0.247/bin/nanoDebugBridge/darwin-arm64/nanoFramework.Tools.DebugBridge
[NanoBridge] Sending: {"command":"initialize","id":1,"args":{"device":"/dev/cu.usbserial-A5069RR4","verbose":false,"verbosity":"information"}}
[NanoBridge] Sending: {"command":"getThreads","id":2,"args":{}}
[NanoBridge] Received: {"event":"output","body":{"category":"console","output":"[nF-Debug] Verbosity level set to: Information\n"}}
[nF-Debug] Verbosity level set to: Information
[NanoBridge] Bridge stderr: [DebugBridge:Info] Verbosity level set to: Information
[NanoBridge] Received: {"id":1,"success":true,"error":null,"data":{"version":"1.0.0","capabilities":["breakpoints","variables","stepping"]}}
[NanoBridge] Sending: {"command":"connect","id":3,"args":{"device":"/dev/cu.usbserial-A5069RR4"}}
[NanoBridge] Received: {"id":2,"success":true,"error":null,"data":[]}
[NanoBridge] Received: {"event":"output","body":{"category":"console","output":"[nF-Debug] Connecting to device: /dev/cu.usbserial-A5069RR4 at baud rate 921600\n"}}
[nF-Debug] Connecting to device: /dev/cu.usbserial-A5069RR4 at baud rate 921600
[NanoBridge] Bridge stderr: [DebugBridge:Always] Connecting to device: /dev/cu.usbserial-A5069RR4 at baud rate 921600
[NanoBridge] Bridge stderr: Fatal error.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
[NanoBridge] Bridge stderr:    at System.Nullable`1[[System.Threading.CancellationToken, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].get_HasValue()
   at nanoFramework.Tools.Debugger.NFDevice.GlobalExclusiveDeviceAccess.GetOrCreate(System.String, Int32, System.Nullable`1<System.Threading.CancellationToken>)
   at nanoFramework.Tools.Debugger.NFDevice.GlobalExclusiveDeviceAccess.TryGet(System.String, Int32, System.Nullable`1<System.Threading.CancellationToken>)
   at nanoFramework.Tools.Debugger.PortSerial.DeviceWatcher+<>c__DisplayClass22_1+<<StartWatcher>b__2>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[nanoFramework.Tools.Debugger.PortSerial.DeviceWatcher+<>c__DisplayClass22_1+<<StartWatcher>b__2>d, nanoFramework.Tools.DebugLibrary.Net, Version=2.5.0.0, Culture=neutral, PublicKeyToken=e520bb6b53f04733]].ExecutionContextCallback(System.Object)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[nanoFramework.Tools.Debugger.PortSerial.DeviceWatcher+<>c__DisplayClass22_1+<<StartWatcher>b__2>d, nanoFramework.Tools.DebugLibrary.Net, Version=2.5.0.0, Culture=neutral, PublicKeyToken=e520bb6b53f04733]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[nanoFramework.Tools.Debugger.PortSerial.DeviceWatcher+<>c__DisplayClass22_1+<<StartWatcher>b__2>d, nanoFramework.Tools.DebugLibrary.Net, Version=2.5.0.0, Culture=neutral, PublicKeyToken=e520bb6b53f04733]].ExecuteFromThreadPool(System.Threading.Thread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()
[NanoBridge] Bridge process exited with code null
[NanoRuntime] Disconnecting (terminate: false)
[NanoBridge] Sending: {"command":"disconnect","id":4,"args":{"terminateDebuggee":false}}

How to reproduce

  1. In macOS, Install Visual Studio Code Insiders
  2. Add .NET nanoFramework pre-release vs code extension (latest)
  3. A simple program as shown below
using System;
using System.Threading;
using System.Diagnostics;

namespace simpleapp
{
    public class Program
    {
        public static void Main()
        {
            Debug.WriteLine("Hello from nanoFramework!");
            Console.WriteLine("Hello from nanoFramework!");
        }
    }
}
  1. Connect to ESP32_REV3 and flash and deploy the above program
  2. Flash - nanoff flash --target ESP32_REV3 --fwversion 2.0.0-preview.391 --preview --serialport /dev/tty.usbserial-A5069RR4 --masserase
  3. Deploy - esptool --port /dev/cu.usbserial-A5069RR4 write-flash 0x1E0000 "/Users/xxxx/Projects/xxxx/hackathon/mantis/simpleapp/bin/Debug/simpleapp.bin"
  4. Start Debugging

Expected behaviour

Break point should be hit and debugging has to work.

Screenshots

No response

Aditional context

.NET 10
Visual Studio Code Insiders Version: 1.136.0-insider
macOS Tahoe Version 26.6.1
nanoff --version 3.0.0-preview.1
nanoFramework pre-release vs code extension 1.0.249
Discord Link - https://discord.com/channels/478725473862549535/1542614194904367255/1542881804527345774

Activity

  1. Ellerbach commented on Aug 30, 2026

    @Ellerbach
    Member

    Just a quick question: as you are flashing your device with preview (so the development branch containing generics), the project must also be of the preview type with mscorelib and all the other libs as preview.

  2. fingers10 commented on Aug 30, 2026

    @fingers10
    Author

    Can you please help me understand what I'm missing? do I need to run any extra commands to do that?

    nfproj:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
      <PropertyGroup Label="Globals">
        <NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
      </PropertyGroup>
    
      <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
    
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
        <ProjectGuid>c5d8e72f-1a3b-4c6d-9e0f-8b7a2d4e5f1c</ProjectGuid>
        <OutputType>Exe</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <FileAlignment>512</FileAlignment>
        <RootNamespace>blinkly</RootNamespace>
        <AssemblyName>blinkly</AssemblyName>
        <TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
      </PropertyGroup>
    
      <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
    
      <ItemGroup>
        <Reference Include="mscorlib">
          <HintPath>..\packages\nanoFramework.CoreLibrary.1.17.12\lib\mscorlib.dll</HintPath>
        </Reference>
        <Reference Include="nanoFramework.Runtime.Events">
          <HintPath>..\packages\nanoFramework.Runtime.Events.2.0.1\lib\nanoFramework.Runtime.Events.dll</HintPath>
          <Private>True</Private>
        </Reference>
        <Reference Include="System.Device.Gpio">
          <HintPath>..\packages\nanoFramework.System.Device.Gpio.1.1.64\lib\System.Device.Gpio.dll</HintPath>
          <Private>True</Private>
        </Reference>
        <None Include="packages.config" />
        <Compile Include="Program.cs" />
        <Compile Include="Properties\AssemblyInfo.cs" />
      </ItemGroup>
    
      <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
    
      <ProjectExtensions>
        <ProjectCapabilities>
          <ProjectConfigurationsDeclaredAsItems/>
        </ProjectCapabilities>
      </ProjectExtensions>
    
    </Project>
    

    packages.config:

    <?xml version="1.0" encoding="utf-8"?>
    <packages>
      <package id="nanoFramework.CoreLibrary" version="1.17.12" targetFramework="netnano1.0" />
      <package id="nanoFramework.Runtime.Events" version="2.0.1" targetFramework="netnano1.0" />
      <package id="nanoFramework.System.Device.Gpio" version="1.1.64" targetFramework="netnano1.0" />
    </packages>
    
  3. alberk8 commented on Aug 31, 2026

    @alberk8

    just flash the stable firmware
    nanoff flash --target ESP32_REV3 --update --serialport /dev/tty.usbserial-A5069RR4 --masserase

  4. josesimoes commented on Sep 24, 2026

    @josesimoes
    Member

    @fingers10 are you still having issues using the latest version?

  5. fingers10 commented on Sep 24, 2026

    @fingers10
    Author

    Yep I'm good. It's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions