the source file is different from when the module

2019-01-08 07:17发布

This is driving me crazy.

I have a rather large project that I am trying to modify. I noticed earlier that when I typed DbCommand, visual studio did not do any syntax highlighting on it, and I am using using System.Data.Common.

Even though nothing was highlighted, the project seemed to be running fine in my browser. So I decided to run the debugger to see if things were really working as they should be.

Every time the class that didn't do the highlighting is called I get the "the source file is different from when the module was built" message.

I cleaned the solution and rebuilt it several times, deleted tmp files, followed all the directions here Getting "The source file is different from when the module was built.", restarted the web server and still it tells me the source files are different when they clearly are not.

I cannot test any of the code I have written today because of this.

  • How can the source be different than the binary when I just complied it?
  • Is there any way to knock some sense into visual studio, or am I just missing something?

26条回答
戒情不戒烟
2楼-- · 2019-01-08 08:11
  1. Delete all breakpoints.
  2. Rebuild.
  3. Done
查看更多
劫难
3楼-- · 2019-01-08 08:13

I was just having this same problem, my projects were all in the same solution so they were using Project to Project references, so as one changed the others should have been updated. However it was not the case, I tried to build, rebuild, close VS2010, pulled a new copy from our source control. None of this worked, what I finally ended up trying was right clicking on the project and rebuilding each project individually. That updated the .dlls and .pdb files so I could debug through.

The issue here is that your dll and or your pdb files are not in sync.

查看更多
地球回转人心会变
4楼-- · 2019-01-08 08:13

My problem was that I had two projects in my solution. The second one was a test project used to call the first one. I had picked the path to the references from the bin folder's release folder.

So whenever I made a change to the first project's code and rebuilt it, it would update the dlls in the debug folder but the calling project was pointing to the release folder, giving me the error, "the source file is different from when the module was built."

Once I deleted the reference to the main project's dll in the release folder and set it to the dll in the debug folder, the issue went away.

查看更多
小情绪 Triste *
5楼-- · 2019-01-08 08:13

I was using Visual Studio 2013 and I had an existing project under source control.
I had downloaded a fresh copy from source control to a new directory.
After making changes to the fresh copy, when building I received the error in question.

My solution:
1) Open Documents\IISExpress\config\applicationhost.config
2) Update virtualDirectory node with directory to the fresh copy and save.

查看更多
何必那么认真
6楼-- · 2019-01-08 08:13

This error also happens if you try to make changes to a source file that is not part of the project.

I was debugging a method from a .dll of another one of my projects, where Visual Studio had quite helpfully loaded the source because the .dll had been built on the same machine and it knew the path to the source. Obviously, changing such a file isn't going to do anything unless you rebuild the referenced project.

查看更多
爱情/是我丢掉的垃圾
7楼-- · 2019-01-08 08:14

I had this problem, and it turns out I was running my console application as a windows application. Switching the output type back to console fixed the issue.

查看更多
登录 后发表回答