Main Site Documentation

StartCDC_WithDebugging works, but StartCDC does not


I have developed a fairly extensive app using USB Client CDC. During development I used:

cdc = USBClientController.StandardDevices.StartCDC_WithDebugging();

Once this was working, I tried replacing it with:

cdc = USBClientController.StandardDevices.StartCDC();

This is the only difference between the two versions. My app also has a flashing LED (toggled on a Timer callback) and a message on a serial LCD display which is loaded from the Main() routine in the program.

The WithDebugging version works fine - when I interrupt the USB connection (to cycle the power) I can see, in Device Manager, first the “GHI.NET Micro Framework USB Debugging Interface” and then “CDC Interface (Virtual COM Port)(COM6)”

However the CDC only version behaves oddly: The “Debugging Interface” appears, but the “CDC Interface” does not, and the LCD message shows, but the flashing LED does not operate. It seems that the Main routine code is running OK, but the Timer interrupt is not firing.

When I try to run this second version using “Start Debugging” in Visual Studio it gives “An unhandled exception of type ‘System.InvalidOperationException’ occurred in GHIElectronics.NETMF.USBClient.dll”.

Does using a USBC interface that does not support debugging require debugging to be switched over to the serial port even when running stand-alone (i.e. with a Release build and without Visual Studio)? If this is the problem, surely this restriction is unnecessary because the original USB “Debugging Interface” is still available up to the point where the application code initialises another interface?


The problem just seems because you are not switching debugging to serial. This is mandatory. Connect the MODE pin to change debug interface. No need to connect an actual serial port just a resistor on RX pin. See this:

If you still have problems, debug over serial port to find out what is happening.


Thanks Mike,

Unfortunately I will now have to re-think my electronics design since I had used COM1 already for the display. It is a pity there is no way to switch off the debugging link altogether once the program is debugged.

It would also be a good idea to be more explicit about this requirement in the docs. I had read the reference you mention, but assumed that doing this would simply mean I would loose the ability to debug past the point where the StartCDC call was executed (i.e. I would not be able to reconnect after the call as I can on the _WithDebugging version). Though on reflection, I should have been concerned about how I would get back to debugging if this had succeeded!

As a final comment, do you have any plans to take the CDC driver up to the same level of functionality as the SerialPort object? In particular the lack of a DataReceived event makes it harder to work with.


CDC does not have events internally. Data has to be polled in a thread and then issue DataReceived event…
We leave this to the user to customize to their application.