Warning provided when debugging source code in visual studio 2010

I set a breakpoint in the source code, but this will give me a warning that the source code is different from the source. This will not affect the breakpoint. This place allows you to change the source code. can anyone explain to me that this is a problem?

+4
source share
6 answers

The checksum of the source file does not match the checksum in the PDB file.

To resolve this issue, open the solution.

Workaround: in the Location property of checking the breakpoint Allow source code to be different

+4
source

This can happen when you compile and run release builds. In Release builds, the compiler does an optimization that can modify or delete parts of the code, in this example:

 static void Main() { int x = 10 + 5; // <---- BREAKPOINT HERE Console.WriteLine("Foo"); } 

If you compile and run this code in a debug assembly, the breakpoint will be deleted, as usual. In the release build, the compiler will see that β€œx” is never used and will β€œoptimize” the entire line, which means that the breakpoint will never be deleted!

+3
source

Do Build -> Clean Solution, then Build -> Build Solution. Then try debugging again, ensuring that the active configuration is debugged.

+2
source

The source code does not match the compilation time. You can stop, clean and rebuild your project.

+2
source

I had this problem when I had a class library in one solution and a web project in another solution. After going through the code in websolution, he went to my class library. This caused the class library files to open in my web solution.

My problem arose when I changed the code in my class library. As usual, I worked on both projects in the correct order. However, I would receive a message stating that the source code is different. This was due to the fact that I had an older β€œview” of class files, which is still open in my web solution , caused by a disabled option .

Options> Environment> Detect when a file is modified outside of the environment

Closing class files in my web project solved my problem. Now I am changing this parameter.

Hope this helps someone.

+1
source

The above suggestions did not work for me when doing unit tests - I did a clean one and rebuilt for the whole solution, but the DLL and PDB files were not deleted in the ~ \ UnitTests \ bin \ Debug directory, so I had to manually delete these files, then right-click in the UnitTests directory and select "Build".

Please note that in my case I am using Visual Studio 2013 with Update 3.

UPDATE:

The creation of a batch file for cleaning and building my solution has been completed, so that Visual Studio does not leave the project incorrectly without rebuilding them:

 msbuild.exe "MyClassLibrary\MyClassLibrary.csproj" /t:Rebuild /p:Configuration=Debug msbuild.exe "UnitTests\UnitTests.csproj" /t:Rebuild /p:Configuration=Debug 
0
source

Source: https://habr.com/ru/post/1391839/


All Articles