简体   繁体   English

为什么调试器不更新?

[英]Why won't the debugger update?

Ive had this problem multiple times and it ruins my projects, I make some changes, like say I have a button in the top left corner of the form and move it to the top right corner, then I press debug but nothing happens to the form, it doesn't change the button is still in the top left-hand corner instead of the top right, and it also doesn't except any new code, its like it saved the project right there and won't move on.我多次遇到这个问题,它破坏了我的项目,我做了一些更改,比如说我在表单的左上角有一个按钮并将其移动到右上角,然后我按下调试但表单没有任何反应,它不会改变按钮仍然在左上角而不是右上角,并且除了任何新代码之外它也没有,就像它在那里保存了项目并且不会继续前进。 Does any one know why or had this problem before?有谁知道为什么或以前有这个问题?

Please, Help!!!!请帮忙!!!!

Additional Details: Compiler: Microsoft Visual C# 2008 Express Edition I once fixed this problem by rebuilding the solution, but its never worked again.其他详细信息: 编译器:Microsoft Visual C# 2008 Express Edition 我曾经通过重建解决方案解决了这个问题,但它再也没有工作过。

嘿,我把它修好了,我在解决方案资源管理器中右键单击 Form1,单击属性并将构建操作更改为无,然后返回编译,它似乎正在工作。

SwDevMan81 and Tanner's answers didn't work for me. SwDevMan81 和 Tanner 的回答对我不起作用。

However,然而,

Build > Rebuild Solution构建 > 重建解决方案

... did! ... 做过!

In the Visual Studio settings under Projects and Solutions->Build and Run change the option On Run, when projects are out of date: from Never Build to Always Build在 Projects and Solutions->Build and Run 下的 Visual Studio 设置中,更改选项 On Run,当项目过期时:从 Never Build 到 Always Build

Tools > Options > Projects and Solutions > Build and Run > On Run, when projects are out of date: "Always Build"工具 > 选项 > 项目和解决方案 > 构建和运行 > 运行时,当项目过期时:“始终构建”

In addition to @SwDevMan81's answer with whom I agree, I would say that setting both the output and reference paths may help avoid such behaviour for class libraries.除了我同意的@SwDevMan81 的回答之外,我想说同时设置输出和引用路径可能有助于避免类库的这种行为。 For instance, your application references a class library that you are currently writing, and you perform some changes to this referenced library, but the changes don't show.例如,您的应用程序引用了您当前正在编写的类库,并且您对该引用的库执行了一些更改,但这些更改没有显示出来。

What happens is that the compiler will copy localy (to the project's output directory) thereferenced DLL and as long as it is there, it won't get updated.发生的情况是编译器将在本地(到项目的输出目录)复制引用的 DLL,只要它在那里,它就不会被更新。 You may verify it by clicking right on the referenced assembly, then clicking Properties.您可以通过在引用的程序集上单击右键,然后单击属性来验证它。 Look at the Filepath property.查看 Filepath 属性。 If you see it doesn't match your actual filepath, then you will have to make sure to set the reference path accordingly in the project properties, then removing then removing the actual reference to add it where the actual build is, that is, where your class library output folder is set.如果您发现它与您的实际文件路径不匹配,那么您必须确保在项目属性中相应地设置引用路径,然后删除然后删除实际引用以将其添加到实际构建所在的位置,即您的类库输出文件夹已设置。 So, whenever you regenerate your class library, your application gets the update automatically.因此,每当您重新生成类库时,您的应用程序都会自动获取更新。 Here's an example:这是一个例子:

Application Project references : The ClassLibrary1.dll assembly.应用程序项目参考ClassLibrary1.dll程序集。

Once you will generate your application, the ClassLibrary1.dll file will be copied to your application output directory.生成应用程序后,ClassLibrary1.dll 文件将被复制到应用程序输出目录。 Let's suppose C:\Open\Projects\ApplicationProject1\Debug\bin .假设C:\Open\Projects\ApplicationProject1\Debug\bin So, this directory will now contain the ClassLibrary1.dll file.因此,该目录现在将包含ClassLibrary1.dll文件。

  1. You rewrite a method to behave completely differently;你重写了一个方法来表现完全不同;
  2. You regenerate the ClassLibrary1 assembly;您重新生成 ClassLibrary1 程序集;
  3. You rerun your application (remember that the file already exists!);您重新运行您的应用程序(记住该文件已经存在!);
  4. Ends up wondering why the changes didn't take effect?最后想知道为什么更改没有生效? That is because your application referenced the cached assembly within its Debug\bin folder.这是因为您的应用程序在其Debug\bin文件夹中引用了缓存的程序集。

To workaround:解决方法:

  1. Remove the assembly reference from your application project;从您的应用程序项目中删除程序集引用;
  2. Go to the project's properties and click the Reference Path tab;转到项目的属性,然后单击参考路径选项卡;
  3. Browse to your ClassLibrary1 output folder, then open it;浏览到您的 ClassLibrary1 输出文件夹,然后打开它;
  4. Your Reference Path property is now set for this library, then re-add the ClassLibrary1 assembly to your application project;现在为这个库设置了您的引用路径属性,然后将 ClassLibrary1 程序集重新添加到您的应用程序项目中;
  5. Run once, stop running, and see if the Path property of your referenced assembly is still the same as the one in the project's Reference Path property;运行一次,停止运行,看看你引用的程序集的Path属性是否还和项目的Reference Path属性中的一样;
  6. You're done (if everything worked fine).你完成了(如果一切正常)。 C:\Open\Projects\ClassLibrary1\Debug\bin\ClassLibrary1.dll C:\Open\Projects\ClassLibrary1\Debug\bin\ClassLibrary1.dll

In the end, this might be the cause of your problem if your GUI Forms are part of a class library, and the solution I described should work.最后,如果您的 GUI 表单是类库的一部分,那么这可能是您的问题的原因,并且我描述的解决方案应该可以工作。

Had The Same issue.有同样的问题。 Build > Rebuild Solution also worked for me构建 > 重建解决方案也对我有用

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

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