C# 获取“源文件与构建模块时不同。”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/353421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 00:15:06  来源:igfitidea点击:

Getting "The source file is different from when the module was built."

c#.netasp.netcompiler-construction

提问by

I'm trying to debug an ASP.Net web project that I received. I modified a class in the "Apps_LocalResources"folder.

我正在尝试调试我收到的 ASP.Net Web 项目。我修改了"Apps_LocalResources"文件夹中的一个类。

When I debug and the code tries to step into that class, I get

当我调试并且代码尝试进入该类时,我得到

"The source file is different from when the module was built.".

“源文件与构建模块时不同。”。

I rebuilt the solution and didn't get any change. I even published it to a different location and the pdb and dll in the bin folder didn't change so I didn't copy them over.

我重建了解决方案并没有得到任何改变。我什至将它发布到不同的位置,bin 文件夹中的 pdb 和 dll 没有改变,所以我没有复制它们。

Ideas?

想法?

回答by StingyHyman

If you are attaching to asp.net worker process, then kill the process, start up the website and reattach the debugger.

如果您要附加到 asp.net 工作进程,则终止该进程,启动网站并重新附加调试器。

If you are using the built in web server, then make sure you stop the project and the WebDev.WebServer.Exe associated with it.

如果您使用的是内置 Web 服务器,请确保停止项目和与其关联的 WebDev.WebServer.Exe。

If all else fails, right click on the breakpoint and choose locations. Then enable the "allow code to be different..." check box at the bottom.

如果所有其他方法都失败,请右键单击断点并选择位置。然后启用底部的“允许代码不同...”复选框。

回答by Sibiraj

Just delete Obj file from application root and rebuild

只需从应用程序根目录中删除 Obj 文件并重建

回答by RodoUY

Delete the folder root under (4ex): C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root

删除(4ex)下的文件夹根目录:C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root

And then in VS2005: Tools->Options->Debugging-> General and uncheck Require source file to exactly match the original version

然后在 VS2005 中:工具->选项->调试->常规并取消选中需要源文件以完全匹配原始版本

This was the solution for me.

这是我的解决方案。

回答by mtzaldo

Click the refresh button at the Solution Explorer. That solved the issue for me.

单击解决方案资源管理器中的刷新按钮。那为我解决了这个问题。

Edit 7/8/2013: Also check that you don't have multiple versions of the same dll between your project. If you do, keep the latest one in the project solution and the rest in a folder outside your project scope. I do recommend that you have a Libraries folder to put all your dlls, so you don't have dlls in multiple folders.

2013 年 7 月 8 日编辑:还要检查您的项目之间是否没有相同 dll 的多个版本。如果这样做,请将最新的一个保存在项目解决方案中,其余的保存在项目范围之外的文件夹中。我建议你有一个 Libraries 文件夹来放置你所有的 dll,这样你就不会在多个文件夹中放置 dll。

回答by Singaravelan

For My case, I depending project file using try catch. It throw the exception so the file can not update. When avoid the exception it works fine.

对于我的情况,我使用 try catch 依赖项目文件。它抛出异常,因此文件无法更新。当避免异常时,它工作正常。

回答by M463

Saying you're referencing a .dll, that is build by a side-project you're modifying along with your main project.

假设您正在引用一个 .dll,它是由您与主项目一起修改的副项目构建的。

If your Reference is set to the .dll-file, that is being built by the Release-Configuration (referred path to the .dll is something like bin\Release\YOURDLL.dll), check if you're really building the side project using the Release-configuration in the configuration manager.

如果您的参考值设为该.dll文件,正在由内置版本构成- (简称路径.dll文件是一样的东西斌\发布\ YOURDLL.dll),检查,如果你真的建设方项目Release在配置管理器中使用-configuration。

configuration manager

配置管理器

Also, assure that your project Dependencies and Build Order are set correctly, so the side-project that your main project is depending on, will be freshly build beforeyour main project is getting build.

此外,请确保您的项目依赖项和构建顺序设置正确,因此您的主项目所依赖的副项目将您的主项目开始构建之前重新构建。

Project dependencies and Build Order

项目依赖项和构建顺序

回答by abkk

Restarting Visual Studio worked for me.

重新启动 Visual Studio 对我有用。