你如何强制 Visual Studio 为 aspx/ascx 文件重新生成 .designer 文件? [英] How do you force Visual Studio to regenerate the .designer files for aspx/ascx files?

查看:35
本文介绍了你如何强制 Visual Studio 为 aspx/ascx 文件重新生成 .designer 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,当我在编辑页面或控件时,.designer 文件会停止使用我放置在页面上的新控件进行更新.我不确定是什么导致了这种情况发生,但我想知道是否有任何方法可以强制 Visual Studio 重新生成 .designer 文件.我正在使用 Visual Studio 2008

Sometimes when I'm editing page or control the .designer files stop being updated with the new controls I'm putting on the page. I'm not sure what's causing this to happen, but I'm wondering if there's any way of forcing Visual Studio to regenerate the .designer file. I'm using Visual Studio 2008

对不起,我应该指出我已经尝试过:

Sorry I should have noted I've already tried:

  • 结束&重新打开所有文件 &视觉工作室
  • 更改页面上的 runat="server" 控件
  • 删除 &重新添加页面指令

推荐答案

如果打开.aspx文件并在设计视图和html视图之间切换,返回它会提示 VS 检查控件并添加任何缺少的控件设计器文件.

If you open the .aspx file and switch between design view and html view and back it will prompt VS to check the controls and add any that are missing to the designer file.

在 VS2013-15 中,Project 菜单下有一个Convert to Web Application 命令.在 VS2013 之前,此选项在 as(c/p)x 文件的右键单击上下文菜单中可用.完成此操作后,您应该会看到您现在有一个可用的 *.Designer.cs 文件,并且您的设计 HTML 中的控件将可供您的控件使用.

In VS2013-15 there is a Convert to Web Application command under the Project menu. Prior to VS2013 this option was available in the right-click context menu for as(c/p)x files. When this is done you should see that you now have a *.Designer.cs file available and your controls within the Design HTML will be available for your control.

PS:这不应该在调试模式下完成,因为调试时并非所有内容都重新编译".

PS: This should not be done in debug mode, as not everything is "recompiled" when debugging.

有些人还通过(制作 .designer.cs 文件的备份副本,然后)删除 .designer.cs 文件报告了成功.重新创建一个同名的空文件.

Some people have also reported success by (making a backup copy of your .designer.cs file and then) deleting the .designer.cs file. Re-create an empty file with the same name.

对此答案有很多评论,其中添加了有关如何最好地重新创建 Designer.cs 文件的提示.

There are many comments to this answer that add tips on how best to re-create the designer.cs file.

这篇关于你如何强制 Visual Studio 为 aspx/ascx 文件重新生成 .designer 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆