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.

Exception caused when method returns a task

See original GitHub issue


I’ve got a really weird bug with MrAdvice. I made a BaseAdvice Abstract class and I have an assembly advice inheriting from it. I’ve got no problems setting the IncludePointcutAttribute and ExcludePointcutAttribute on my assembly advice. Everything works except when I don’t include a method that returns a task. Whenever I do the Task.Start() I get the following exception : System.InvalidOperationException: 'Start may not be called on a continuation task.'

That only happens when you exclude it on the assembly advice. If I include it, it works. If I add [ExcludeAdvices("*")] on my class the contains the method, it works. Also, if I add the ExcludePointcutAttribute on my BaseAdvice class, it also works. That’s really strange. Here’s the code I made to show the problem:


Issue Analytics

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

github_iconTop GitHub Comments

rhap06commented, Oct 7, 2019

Thanks a lot! I confirm everything is now working correctly!

picrapcommented, Sep 18, 2019

Weird indeed… I’ll take a look at it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Should methods that return Task throw exceptions?
Method 1 requires you to catch the exception synchronously (when calling method rather than when awaiting). If you used a continuation ( task....
Read more >
Handling Exceptions in Asynchronous Methods in C# | ...
When an exception is thrown in an async method that returns a Task object, all exceptions are placed on the Task instance and...
Read more >
Exception handling (Task Parallel Library)
Exceptions are propagated when you use one of the static or instance Task.Wait methods, and you handle them by enclosing the call in...
Read more >
Bug - async and uncaught Exceptions
Hello everyone, In one of the projects I'm working on, we're using async and await in order to execute code asynchronously.
Read more >
Why exceptions in async methods are “dangerous” in C# | ...
No exception was thrown because the MyAsyncMethod routine is not awaited and the exception is literally lost with the Task. In that case,...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found