pamidur / aspect-injector

AOP framework for .NET (c#, vb, etc)
Apache License 2.0
745 stars 112 forks source link

Edit & Continue Support | CS7038 #138

Closed oleksandrp1 closed 2 years ago

oleksandrp1 commented 3 years ago

Hi, Thank you for your package. It is very useful, but after adding it to my project I cannot change my code during the debugging session. Each time I receive the following code after a change of at least one symbol: CS7038 Failed to emit module 'project name': Changing the version of an assembly reference is not allowed during debugging: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' changed version to '2.1.0.0'. The error disappears when I remove the package.

pamidur commented 3 years ago

Hi @oleksandrp1 , do you mean "edit and continue feature"?

oleksandrp1 commented 3 years ago

image I receive the following message.

pamidur commented 3 years ago

Thanks for the report, I'll look into it

oleksandrp1 commented 3 years ago

The error disappears if I remove and install the package again. But the error appears after the second launch of the Visual Studio,

pamidur commented 3 years ago

I've found the cause of the issue, but can't figure how to fix it at the moment :(

oleksandrp1 commented 3 years ago

Hi pamidur. After update to 2.5.0 version, the following warning message appears during debugging. The problem disappears if I remove the package. image The bug is also available in 2.4.4 version and absents in 2.4.3.

pamidur commented 3 years ago

hi @oleksandrp1 , do you use 'Edit&Continue' feature ? and if no, could you please provide a bit more information. maybe sample code?

oleksandrp1 commented 3 years ago

Yes, I use 'Edit&Continue' feature.

pamidur commented 3 years ago

The weird part that is should also fail in 2.4.3 then! And you're saying it doesn't. Very interesting! Is there any chance you could provide code sample and/or steps to reproduce?

oleksandrp1 commented 3 years ago

Excuse me. I mixed 2 problems in one issue. The error with the "Edit" and "Stop" buttons appears in 2.4.3, 2.4.4, and 2.5.0 versions. The error about breakpoints appears in 2.4.4 and 2.5.0. It does not appear in 2.4.3.

pamidur commented 3 years ago

In 2.4.4 I changed (fixed) the way debug data is handled. It seems like something isn't working as expected. Could you please create another issue and provide steps to reproduce and code sample (the method where you try to set breakpoint) if possible?

oleksandrp1 commented 3 years ago

Example.zip This is an attachment for this problem, but the bug about the breakpoint is not reproduced here. It is a simplified version of my project, but now I did not find what causes the breakpoint problem. I will investigate it later.

pamidur commented 3 years ago

Thanks for your report! The sample code will help a lot!

oleksandrp1 commented 3 years ago

The problem with the breakpoints is not reproduced now at all. Maybe cleaning the project and update of other packages solved the problem.

pamidur commented 3 years ago

well, it potentially could be a weird extension of Edit&Continue bug

marbel82 commented 3 years ago

A similar problem: https://github.com/AvaloniaUI/Avalonia/issues/5456

pamidur commented 3 years ago

Hi @marbel82 , have tried 2.6.0-pre1 version?

oleksandrp1 commented 3 years ago

In 2.6.0-pre1 it is possible to debug the code and to go to highest rows in the code, but after changing the code it shows the message image

pamidur commented 3 years ago

@oleksandrp1 , could you please provide a code-sample (or project-sample) so we can reproduce it?

oleksandrp1 commented 3 years ago

Example.zip Hi, now the message does not appear, but I found that if I add changes to the code during debugging then they will not be applied to the code during the debugging. Open WebRefactorPage.cs and make a breakpoint on string 23 and on string 25. Run debugging a test in TS09General.cs file. If you change the "a" variable to "true" on string 23 then it will not be applied to the debugging mode and the step 25 will apply the previous "false" value.

pamidur commented 3 years ago

Hi @oleksandrp1 , Thank you for detailed steps and sample code. I'll use it to reproduce and fix the bug!

oleksandrp1 commented 3 years ago

Thank you for your product!

JunkyXL86 commented 3 years ago

I've got the same error trying to change code in a Xamarin.Forms 5.0.0.2012 App using Edit & Continue with Visual Studio 2022 Preview 3.1: CS7038 Failed to emit module 'XF.App': Changing the version of an assembly reference is not allowed during debugging: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' changed version to '2.1.0.0'.

marbel82 commented 3 years ago

I found the cause in my case. In all projects I have set TargetFramework to net5.0-windows, but in one I had set net.5.0. When I changed in this latest project to net5.0-windows, the problem with inability to edit disappeared.

pamidur commented 2 years ago

@JunkyXL86 , @marbel82 which version were you using, please?

marbel82 commented 2 years ago

@pamidur I use Visual Studio 16.11.3

pamidur commented 2 years ago

An which version of AspectInjector? this is also important

marbel82 commented 2 years ago

:) I just wrote that I have similar problem. I'm not using AspectInjector.

pamidur commented 2 years ago

oh, I got it, it does mean that issue could be somewhere else, thanks @marbel82

pamidur commented 2 years ago

Seems fixed in 2.7.0