ArxOne / MrAdvice

.NET aspect weaver (build task under NuGet package)
MIT License
311 stars 45 forks source link

Can't load MrAdvice assembly (WTF?), exiting #123

Closed jon-peel closed 6 years ago

jon-peel commented 6 years ago

I am having this annoyance.

I am using Xamarin forms to develop an Android application and using MrAdvice (which I am loving for small things, like run on the main thread or set a flag to busy while this method is running).

The annoying part is that I need to remove it and then re-add it every time I want to execute the application.

I have the NuGet installed on my shared project (.NetStandard) and on the Android project. When I want to run the applications, it builds (successfully), and then MrAdvice dies...

    1>Done building project "Igs.Mobile.RoadStop.Android.csproj".
    1>Build succeeded.
    1>Can't load MrAdvice assembly (WTF?), exiting
    1>

I remove the NuGet (just from the Android project), add it again, and it builds, and runs without any trouble.

I would be happy to send any logs (if you tell me where to find them) or do any testing.

picrap commented 6 years ago

Sorry to read that. What if you restart your build environment (your IDE, I mean, not your OS)? Does it help? I'm aware of this problem, I also get it sometimes, but I was never able to resolve it. I'll take a look at it again this week-end.

jon-peel commented 6 years ago

reinstalling the NuGet sorts it out straight away, but it comes up again every half an hour or so.

Restarting VS (Windows) might help, but reinstalling the NuGet would be quicker, so I have never tried. It has been happening for a month or two, so restarting VS, or PC isn't a "final" solution.

picrap commented 6 years ago

Of course restarting VS is not a final solution, only a fix would be 😄

picrap commented 6 years ago

I released a version named MrAdvice.2.5.18-exp3 (accessible if you enable the pre-releases listing). Could you give it a try? (this is a blind test, so don't expect too much from it anyway). Edit: this stupid NuGet will tell you that they are more recent version. Don't belive it, believe me instead. NuGet sorts versions alphetically, yes it is stupid.

jon-peel commented 6 years ago

I will do that. I am not going to know if anything has changed until I spend a few hours working with it though.

picrap commented 6 years ago

There is a MrAdvice.2.5.18-exp4 with early diagnostic.

jon-peel commented 6 years ago

Thanks, I have just gotten back to work, and I see there is now a .19 Should I be using 19, or 18-exp4?

On Sun, 17 Dec 2017 at 16:34 Pascal Craponne notifications@github.com wrote:

There is a MrAdvice.2.5.18-exp4 with early diagnostic.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ArxOne/MrAdvice/issues/123#issuecomment-352259876, or mute the thread https://github.com/notifications/unsubscribe-auth/AON4uIRWW2t0LqLxrazSxmSvj4tjd3Pbks5tBSZ8gaJpZM4RDEOo .

picrap commented 6 years ago

Hi, I was about to tell you that you can try the version 2.5.19, so yes, go for it.

picrap commented 6 years ago

@Thorocaine Any news?

jon-peel commented 6 years ago

Not yet, sorry, it seems with Xamarine there are a hundered other things that can start breaking when chaning something. I can't remember if I left it on the latest or not. I will let you know later today if it is running.

On Tue, 19 Dec 2017 at 20:48 Pascal Craponne notifications@github.com wrote:

@Thorocaine https://github.com/thorocaine Any news?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ArxOne/MrAdvice/issues/123#issuecomment-352850748, or mute the thread https://github.com/notifications/unsubscribe-auth/AON4uNFx9YkJldhyoSG8rVC3LS7xE17eks5tCAUJgaJpZM4RDEOo .

jon-peel commented 6 years ago

Hi, I am sorry I have been so quiet on this. I am still using 2.5.17, but I haven't gotten this error in a while. I am not sure what may have changed, maybe something in Xamarin or VS updated.

picrap commented 6 years ago

OK, I keep the issue open until february. If the issue comes back after that, you can either reopen this issue or create a new one. Thanks for feedback.

rgroenewoudt commented 6 years ago

With Xamarin and latest 2.5.25 I'm getting a different issue. MrAdvice build task runs fine but when trying to debug with Xamarin:

2>Failed to read 'bin\Debug\SequriX.Android.dll' with debugging symbols. Retrying to load it without it. Error details are logged below.
2>System.ArgumentOutOfRangeException: Non-negative number required.
2>Parameter name: count
2>   at System.IO.BinaryReader.ReadBytes(Int32 count)
2>   at Mono.Cecil.PE.ImageReader.ReadDebugHeader()
2>   at Mono.Cecil.PE.ImageReader.ReadImage()
2>   at Mono.Cecil.PE.ImageReader.ReadImage(Disposable`1 stream, String file_name)
2>   at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
2>   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file)
2>Exception while loading assemblies: Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA0009: Error while loading assembly: bin\Debug\SequriX.Android.dll ---> System.ArgumentOutOfRangeException: Non-negative number required.
2>Parameter name: count
2>   at System.IO.BinaryReader.ReadBytes(Int32 count)
2>   at Mono.Cecil.PE.ImageReader.ReadDebugHeader()
2>   at Mono.Cecil.PE.ImageReader.ReadImage()
2>   at Mono.Cecil.PE.ImageReader.ReadImage(Disposable`1 stream, String file_name)
2>   at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
2>   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file)
2>   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Load(String fileName, Boolean forceLoad)
2>   --- End of inner exception stack trace ---
2>   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Load(String fileName, Boolean forceLoad)
2>   at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)
2>Done building project "Android.csproj" -- FAILED.
2>Build FAILED.

MrAdvice changes the resulting assembly and Xamarin can't load it anymore.

picrap commented 6 years ago

dnlib was improved, apparently 🤔 I'll see if there are other options to generate PDB and let you know.

rgroenewoudt commented 6 years ago

Are there any updates about this issue? I see dnlib has been upgraded.

picrap commented 6 years ago

Is it still not working?

rgroenewoudt commented 6 years ago

Ah, yes it's working! Thank you. You can close this ticket.

picrap commented 6 years ago

I am the first to be surprised, but OK :)