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 07:57

I also experienced that. I just open the obj folder on the project and then open the debug folder delete the .pdb file and that's all.

查看更多
来,给爷笑一个
3楼-- · 2019-01-08 07:58

I got this issue running a console app where the source that was different was the source that had the entry-point (static void Main). Deleting the bin and obj directories and doing a full rebuild seemed to correct this, but every time I made a code change, it would go out-of-date again.

The reason I found for this was:

  1. I had checked "Only build startup projects and dependencies on Run" (Tools -> Options -> Projects and Solutions -> Build and Run)
  2. In Configuration Manager, my start-up project didn't have "Build" checked

(For #2 -> accessible via the toolbar under the 'Debug/Release' drop down list.)

查看更多
ゆ 、 Hurt°
4楼-- · 2019-01-08 07:58

With web services, the problem can be caused by using the Visual Studio "View in Browser" command. This places the service's DLL and PDB files in the bin and obj folders. When stepping into the web service from a client, somehow Visual Studio uses the PDB in the bin (or obj) folder, but it uses the DLL in the project's output build folder. There are a couple workarounds:

  1. Try deleting the DLL and PDB files in the web service bin and obj files.
  2. Try clicking "View in Browser" in Visual Studio.

If you previously got the source file mismatch error, Visual Studio might have added the filename to a black list. Check your solution properties. Choose "Common Properties -> Debug Source Files" on the left side of the dialog box. If your web service source files appear in the field "Do not look for these source files", delete them.

查看更多
欢心
5楼-- · 2019-01-08 07:58

I had this same problem and I followed the majority of the guidance in the other answers posted here, nothing seemed to work for me.

I eventually opened IIS and recycled the application pool for my web application. I have IIS version 8.5.9600, I right-clicked my web application, then: Deploy > Recycle > Recycle application pool > OK.

That seems to have fixed it, breakpoints now being hit as expected. I think that doing this along with deleting the bin and obj folders helped my situation.

Good luck!

查看更多
贼婆χ
6楼-- · 2019-01-08 07:59

I had the same problem. To fix it I used the "Release Mode" to debug in VS2013. Which is sufficient for me, because I'm working in a node js\c++ addon.

查看更多
Fickle 薄情
7楼-- · 2019-01-08 07:59

My problem was that I had a webservice in the project and I changed the build path.

Restoring the default build path solved my issue.

查看更多
登录 后发表回答