question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InvalidOperationException occurs when debugging

See original GitHub issue

Hello! While debugging, I see the following exceptions logged in Visual Studio upon each Cosmos operation, e.g. ReadItemStreamAsync or others. This seems to be associated with IntelliTrace in VS, because when I disable it, the messages no longer appear in the debug console and the operations are significantly faster (I’m assuming IntelliTrace takes time to process each exception).

This isn’t breaking anything as far as I know, just a nuisance in debugging with the output noise and slowdown involved. Wanted to raise here in case there is a way to address it in the SDK.

Exception:

Exception thrown: 'System.InvalidOperationException' in System.Diagnostics.DiagnosticSource.dll (""Can not stop an Activity that was not started"") Exception thrown: 'System.InvalidOperationException' in System.Diagnostics.DiagnosticSource.dll (""Can not stop an Activity that was not started"")

What IntelliTrace looks like:

image

To Reproduce Run project that uses the SDK to do operations, and observe the Debug output and IntelliTrace events tab. I’m using all the stream-based methods in the preview SDK.

Expected behavior Ideally, no exceptions.

Environment summary SDK Version: 4.0.0 preview3 (also happened with preview1) OS Version: Windows 10 1909 VS: Visual Studio Enterprise 16.4.2, local Cosmos emulator System.Diagnostics.DiagnosticSource 4.7.0 referenced in project

Thanks, happy to provide additional info as needed.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
NoahStahlcommented, Jan 13, 2020

It turns out it must have been some setting I changed. After doing Visual Studio’s “Reset all settings” from the Import/Export Settings Wizard, the behavior disappears. My guess is something in the Debug settings, but I’m not sure. Diffing 3000 lines of exported settings XML doesn’t immediately reveal anything. 😃

Anyhow, I’ll mark as closed, sorry to bother!

1reaction
NoahStahlcommented, Jan 13, 2020

Thanks for checking into it. I’ve found that the behavior doesn’t happen on VS 2019 preview, only on 16.4.2, same machine. May be something in my VS installation or environment, I’ll have to fiddle more and see if I can isolate.

Regarding cause, I didn’t mean to suggest SDK was causing, only that there was some interaction. It definitely occurs while stepping over the Cosmos SDK method call in debug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to debug InvalidOperationException
I have seen this quite frequent with Linq2SQL, especially on SQL CE. It likely means the query timed out when the debugger was...
Read more >
InvalidOperationException while debugging Xamarin ...
Here is a bot friendly version of the error stack trace. EXCEPTION: System.InvalidOperationException: Sequence contains no elements at System.
Read more >
Manage exceptions with the debugger in Visual Studio
An exception is an indication of an error state that occurs while a program is being executed. You can tell the debugger which...
Read more >
"Only break on any exception in my code" is not working
InvalidOperationException ) explicitly, the debugger breaks at the expected location. Note that I have to leave "Only break on exception in my code"...
Read more >
Unhandled Exception - System.InvalidOperationException ...
7 I now get an exception when closing the main window (debug mode): Unhandled Exception: System.InvalidOperationException: Operation is not ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found