Error CS7038 (failed to release the module) only in edit and continue mode

I am debugging a .NET 4.0 application in Visual Studio 2015. My application builds and works fine, but when I try to edit and continue working under the debugger, no matter what changes I make or where I create them my main project, I get a dialog, which says:

Changes have been made that cannot be compiled. Execution cannot continue until compiler errors are fixed.

As an example of the change I'm talking about, I tried to add this line to various methods:

Console.WriteLine("foo"); 

When I look in the Visual Studio error list area, I see only one error CS7038 with the description "Failed to fix the module" <my app name> ". There is no file name, line number or symbol. My code does not have clear red underscores. If I I’ll stop the running application, build it with the changes and run it again, everything will build and work fine, so there is some discrepancy between what the build-time compiler and the edit-and-continue compiler consider acceptable.

Does anyone know how to get more information about why compilation doesn't work in edit and continue mode? I read something about connecting and debugging the VBCSCompiler process, so I tried it, but even if all types of exceptions are set to break on throw, the connected VS never broke.

I do not use code because it is not a question of my code, but rather of strategies for figuring out what the Edit and Continue compiler thinks are wrong, and for everyone I know, the source of the compiler error can be anywhere in my entire project.

Edit:

As mentioned in the comments, I was able to connect the debugger to Visual Studio and crash when an exception was thrown after clicking Continue after editing the code. An exception was a System.NotSupportedException with the following message: "Changing the assembly reference version during debugging is not allowed." He listed the name of the assembly in question, which was a small VB.Net project used by my application, which mainly relates to C #. I am trying to create an MCVE to be sent to Microsoft, but currently I cannot reproduce the problem in a smaller solution with only one VB and one C # project.

Edit 2:

I found a workaround and answered this question myself if someone else is faced with this strange problem, but I leave the "Answer" checkbox for anyone who can explain what is happening (why the compiler believes that the version number of the mentioned project has changed to editing time).

+7
c # visual-studio visual-studio-2015 roslyn edit-and-continue
source share
1 answer

I have found a workaround for the problem, but I do not quite understand what is happening. In the VB.NET project, the build version of which the Edit and Continue compiler has changed, the file AssemblyInfo.vb has appeared. This file contained the following line:

 <Assembly: AssemblyVersion("3.0.*")> 

The assembly version can also be set in the project properties via the "Assembly Information" button on the "Application" tab:

screenshot of Visual Studio project properties for a VB.NET project with AssemblyVersion installed in two places

When I deleted the AssemblyVersion line from AssemblyInfo.vb, my Change and Continue problem disappeared. At first I thought that this was because the fields in the Assembly Information window were saved in another file from AssemblyInfo.vb, and there was a conflict between them, but now I see that the Assembly Information window is just convenient way to edit AssemblyInfo.vb: if I delete a line in AssemblyInfo.vb, it will be cleared in the assembly information window.

After several experiments, it seems that the star in the version number is the culprit. If I fully indicate the version of the assembly, my Change and Continue problems will disappear. And the related project should be a VB.NET project. I tried the same installation with a C # project, and I could Edit and continue fine.

This seems to be a very important question, and I will send a bug report to Microsoft, but in the meantime I would be interested to know what is really happening with the compiler - why it gets two different assemblies of the assembly version, which really do not need to be recompiled during debugging. If you have a good explanation of what is happening, add it as an answer.

Edit : here is the error report I filed .

+2
source share

All Articles