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.

Task.Run async ... await fails on .NetCore (.NetFramework works)

See original GitHub issue

May be can be helpful for someone.

Was difficult to find in a big project why the weaving stops without any extra information… This line caused the problem:

 Task.Run(async () => { await OpenSocketHandler(client); });
1>MrAdvice 2.5.24 weaved module 'JCore, Version=1.437.2018.727, Culture=neutral, PublicKeyToken=null' (targeting framework ) in 1632ms
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error : Unhandled exception: dnlib.DotNet.Writer.ModuleWriterException: **Couldn't find an instruction, maybe it was removed. It's still being referenced by some code or by the PDB**
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.DummyLogger.Log(Object sender, LoggerEvent loggerEvent, String format, Object[] args)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.ModuleWriterBase.dnlib.DotNet.ILogger.Log(Object sender, LoggerEvent loggerEvent, String format, Object[] args)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.MetaData.dnlib.DotNet.Writer.IWriterError.Error(String message)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.SerializerMethodContext.GetOffset(Instruction instr)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Pdb.Portable.PortablePdbCustomDebugInfoWriter.WriteAsyncMethodSteppingInformation(PdbAsyncMethodCustomDebugInfo cdi)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Pdb.Portable.PortablePdbCustomDebugInfoWriter.Write(PdbCustomDebugInfo cdi)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.MetaData.AddCustomDebugInformationCore(SerializerMethodContext serializerMethodContext, UInt32 encodedToken, PdbCustomDebugInfo cdi, Guid cdiGuid)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.MetaData.AddCustomDebugInformation(SerializerMethodContext serializerMethodContext, UInt32 token, UInt32 encodedToken, PdbCustomDebugInfo cdi)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.MetaData.AddCustomDebugInformationCore(SerializerMethodContext serializerMethodContext, Table table, UInt32 rid, IList`1 cdis)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.MetaData.AddCustomDebugInformationList(MethodDef method, UInt32 rid, UInt32 localVarSigToken)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.MetaData.WriteMethodBodies()
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.MetaData.Create()
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.MetaData.CreateTables()
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.ModuleWriter.WriteImpl()
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.ModuleWriterBase.Write(Stream dest)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.Writer.ModuleWriterBase.Write(String fileName)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at dnlib.DotNet.ModuleDef.Write(String filename, ModuleWriterOptions options)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at StitcherBoy.Reflection.ModuleManager.Write(String assemblyOriginatorKeyFile)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at StitcherBoy.Weaving.Build.AssemblyStitcher.Process(StringDictionary parameters, Guid buildID, DateTime buildTime, String entryAssemblyPath)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at StitcherBoy.Weaving.StitcherProcessor.Process(StringDictionary parameters, Guid buildID, DateTime buildTime, String entryAsemblyPath)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at StitcherBoy.Weaving.StitcherProcessor.Process(StringDictionary parameters, Guid buildID, DateTime buildTime, String entryAsemblyPath)
1>C:\Users\blaze\.nuget\packages\mradvice\2.5.24\build\MrAdvice.targets(10,5): error :    at StitcherTask`1.Run(Boolean fromExe)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
hhblazecommented, Aug 13, 2018

Works!

1reaction
picrapcommented, Aug 3, 2018

Thanks. I’ll use this to create a .NET core test assembly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Async Await Recursion in .NET 4.8 causes ...
I suspect this behavior doesn't happen on . NET Core because a lot of optimization work has gone into . NET Core's async...
Read more >
Different await Task.Run(async () to without only async
Each function works asynchronously, not waiting. I thought only with Task. ... Run(() => DoWork()); // wait and UI not blocked? await Task....
Read more >
Common async / Task mistakes, and how to avoid them
When running the code as-is, everything works fine. The exception is thrown properly, since we await DoStuff(), which in turn means we are ......
Read more >
Two Ways to Do Async/Await in ASP.NET Wrong (and How ...
There are two things you should keep in mind: Don't wrap asynchronous tasks in another call to Task.
Read more >
Advanced Tips for Using Task.Run with Async/Await
Let's dive deeper into using Task.Run with Async/Await and determine whether or not we should use Task.Run with ASP.NET Core.
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