简体   繁体   English

调试不生效时的代码更改 (Visual Studio 2017)

[英]Code Changes While Debugging Not Taking Effect (Visual Studio 2017)

I'm stepping through my C# program in Visual Studio, trying to test how a generated HTML string will look given a few modifications.我在 Visual Studio 中逐步完成我的 C# 程序,尝试测试生成的 HTML 字符串在进行一些修改后的外观。 After I pause the debugger, modify my code, then continue, the changes do not take effect.在我暂停调试器后,修改我的代码,然后继续,更改不会生效。 I step through the entire method and when I look at the generated HTML string, it's the same as it was before I modified it.我逐步完成整个方法,当我查看生成的 HTML 字符串时,它与我修改它之前的相同。 The changes only take effect if I stop running the program and run it again, which is extremely tedious.只有当我停止运行程序并再次运行时,更改才会生效,这非常繁琐。

Is it caching in some way?它是否以某种方式缓存?

Code Changes While Debugging Not Taking Effect (Visual Studio 2017)调试不生效时的代码更改 (Visual Studio 2017)

In fact , to use that function, every time put the cursor back to the changed part and then step over the cursor, it will take effect.实际上,要使用那个function,每次把cursor放回改变的部分,然后跨过cursor,它就会生效。

So please try these suggestions:所以请尝试以下建议:

Suggestion建议

1) make sure that these settings are checked under Tools --> Options --> Debugging --> General 1)确保在Tools --> Options --> Debugging --> General下检查这些设置

在此处输入图像描述

uncheck Require source files to exactly match the original version under Tools --> Options --> Debugging --> General .取消选中Tools --> Options --> Debugging --> GeneralRequire source files to exactly match the original version

check Managed and uncheck Native under Tools --> Options --> Debugging --> Just In TimeTools --> Options --> Debugging --> Just In Time下选中Managed并取消选中Native

2) close VS Instance, delete .vs hidden folder, bin , obj folder and then restart your project again. 2)关闭VS Instance,删除.vs隐藏文件夹, binobj文件夹,然后重新启动你的项目。

3) If you port an existing project, you should specify EmbedInteropTypes as false . 3)如果您移植现有项目,则应将EmbedInteropTypes指定为false

Add it in xxxx.csproj file.将其添加到xxxx.csproj文件中。

  <PropertyGroup>
 <EmbedInteropTypes>false</EmbedInteropTypes>
  </PropertyGroup>

4) disable any third party extensions under Extensions --> Manage Extension 4)禁用Extensions --> Manage Extension下的任何第三方扩展

5) make sure that you use the Debug mode 5)确保您使用调试模式

If your project is created by an old VS version, try to create a new project in VS2017 and then migrate the content of the old project into the new project to test this.如果你的项目是旧VS版本创建的,尝试在VS2017中新建一个项目,然后将旧项目的内容迁移到新项目中进行测试。 (Not sure if the project is created by an old VS version) (不确定项目是否由旧的 VS 版本创建)

Note that in different versions of vs, they can be some different, and if it is an old project, it may have some problems with this function in VS2017.注意,在不同版本的vs中,可能会有些不同,如果是老项目,在VS2017中这个function可能会有些问题。

Hope it could help you.希望它可以帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM