- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
好的。这个有点傻。
我正在为 Access 数据库编写前端代码(我知道,重新发明轮子)。这个前端很简单。个人可以添加新条目或搜索现有条目。这两个都工作正常。该程序是 self 更新的,但非常简单。它比较已执行程序的当前文件版本(不是程序集),并将自身与远程驱动器版本进行比较,以查看哪个版本更新。如果远程驱动器的可执行文件较新,我会生成一个批处理文件来更新脚本,方法是杀死当前程序,将较新的程序复制到与旧程序相同的目录,然后自动打开新程序。每次用户打开程序时都会进行此更新检查。
我不确定这是否相关,但我最近一直在编辑该过程以在 XP 和 7 上工作。因此,我需要修改它以适应文件路径(文档和设置 - XP)中的空格。一切都很好,花花公子。
突然(似乎),程序开始在我的测试 XP 机器上不断崩溃(在 2 台不同的 XP 机器上验证)。我的个人计算机运行 7,并且完全按预期运行,包括更新,一切正常。
XP 上的崩溃是在我的主页窗体的 InitializeComponent() 中发生的未处理异常。我的表单的快速布局如下:
我们不会进入其他表单,因为它会在加载 Home.cs 表单之前崩溃。
我已将其缩小到在 Home 的 InitializeComponent() 中崩溃,在以下构造函数中:
public Home(string DB)
{
InitializeComponent();
database = DB;
lblVersion.Text = "Version: " + FileVersionInfo.GetVersionInfo(Directory.GetCurrentDirectory() + "\\KnowledgeBase.exe").ProductVersion;
}
并带有以下消息。抱歉有颗粒感...截图截图:我的 rep 不到 10,不会打出错误:
这是我的 InitializeComponent()
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Home));
this.btnNewEntry = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.btnSearch = new System.Windows.Forms.Button();
this.lblVersion = new System.Windows.Forms.Label();
this.linklblChangelog = new System.Windows.Forms.LinkLabel();
this.button1 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// btnNewEntry
//
this.btnNewEntry.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnNewEntry.Location = new System.Drawing.Point(391, 407);
this.btnNewEntry.Name = "btnNewEntry";
this.btnNewEntry.Size = new System.Drawing.Size(142, 43);
this.btnNewEntry.TabIndex = 0;
this.btnNewEntry.Text = "Add new entry";
this.btnNewEntry.UseVisualStyleBackColor = true;
this.btnNewEntry.Click += new System.EventHandler(this.btnNewEntry_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(184, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(349, 31);
this.label1.TabIndex = 1;
this.label1.Text = "Nationwide Knowledgebase";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(280, 41);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(147, 26);
this.label2.TabIndex = 2;
this.label2.Text = "RADS Edition";
//
// btnSearch
//
this.btnSearch.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSearch.Location = new System.Drawing.Point(190, 407);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(142, 43);
this.btnSearch.TabIndex = 3;
this.btnSearch.Text = "Search database";
this.btnSearch.UseVisualStyleBackColor = true;
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// lblVersion
//
this.lblVersion.AutoSize = true;
this.lblVersion.Location = new System.Drawing.Point(3, 485);
this.lblVersion.Name = "lblVersion";
this.lblVersion.Size = new System.Drawing.Size(64, 13);
this.lblVersion.TabIndex = 4;
this.lblVersion.Text = "Version: null";
//
// linklblChangelog
//
this.linklblChangelog.AutoSize = true;
this.linklblChangelog.Location = new System.Drawing.Point(96, 485);
this.linklblChangelog.Name = "linklblChangelog";
this.linklblChangelog.Size = new System.Drawing.Size(58, 13);
this.linklblChangelog.TabIndex = 5;
this.linklblChangelog.TabStop = true;
this.linklblChangelog.Text = "Changelog";
//
// button1
//
this.button1.Location = new System.Drawing.Point(640, 480);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 7;
this.button1.Text = "test";
this.button1.UseVisualStyleBackColor = true;
this.button1.Visible = false;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(232, 85);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(247, 256);
this.pictureBox1.TabIndex = 8;
this.pictureBox1.TabStop = false;
//
// Home
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
this.ClientSize = new System.Drawing.Size(727, 512);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.linklblChangelog);
this.Controls.Add(this.lblVersion);
this.Controls.Add(this.btnSearch);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnNewEntry);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Home";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Home";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Home_FormClosed);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
为什么它仅在 XP 上在 InitializeComponent() 上崩溃?为什么它刚刚开始这样做?该领域前几周的开发进展顺利。
我试过删除整个 Update() 过程,但这并没有改变任何东西。
感谢阅读。
更新:Jon Skeet 建议我使用的图标会导致程序崩溃。事实证明确实如此。删除图标可以让表单在 XP 上正常工作(同样,在 7 上从来都不是问题)。更有趣的是,这个问题等了 2 周才出现,因为我在开发中使用这个图标已经很长时间了。稍后我会分析它发生的原因,但与此同时我还有更多代码要编写。
谢谢大家
最佳答案
鉴于堆栈跟踪,我怀疑这是问题所在:
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
我会通过删除图标来确认这一点,看看是否能解决问题。假设是这样,请查看图标的格式 - 我想知道它是否以某种方式以 XP 无法处理的方式损坏,或者它使用的图像格式比 XP 支持的更新。
当然,如果该图标不重要,您可以将其完全省略 :) 尽管如此,我还是会尝试诊断它发生了什么...
关于c# - 程序在调用 InitializeComponent() 时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17618217/
好吧,我怀疑这可能是 Visual Studio 的问题,但肯定有一些原因。我从默认项目列表创建了一个 ListBox(右键单击项目或项目中的文件夹 -> 添加 -> 新项目 -> Xaml List
我已经尝试开始使用.Net Maui,并且已经按照中所述的步骤设置了开发环境:。我还运行了‘Maui-Check’CLI工具,一切都已检查完毕,但当我使用Visual Studio2019 v16.1
如果我在 Visual Studio 2010 SP1 中创建一个新项目并选择“WPF 应用程序”并尝试构建生成的应用程序,则会收到错误 The name 'InitializeComponent'
InitializeComponent(); 此代码行出现在我所有 Xaml 页面的构造函数中的代码后面。 它引发以下错误: InitializeComponent does not exist. 虽
我承认我是xaml 世界的新手但是看到使用内置 Visual Studio 模板的警告表明可能还有另一个问题除了我的大脑。 如果我创建一个空的 VSIX Project (必须是 VSIX 项目)在
我想了解如何使用 C# 构建文件,因此我创建了一个 Windows 窗体应用程序并创建了此代码/窗体。但它似乎没有用。 . using System; using System.Windows.For
该应用程序是在运行 windows 10 的机器上开发的,系统语言设置为我们的本地语言丹麦语。现在我们正处于需要在其他国家的办公室使用该软件的阶段。但是, View 在这些机器上启动时崩溃,而且我发现
我正在尝试在 WPF 中创建自定义用户控件。我希望以后在另一个窗口中使用该控件时能够手动设置大小。 作为一个简短的测试,我刚刚制作了一个包含网格内 Canvas 的控件,它完全填满了控件。初始化时,它
如果我创建一个 winForms“myForm”,则会生成以下样板代码: public partial class myForm: Form { public myForm() {
我的 WPF 用户控件的公共(public)接口(interface)包含自动生成的 InitializeComponent 方法(包含在部分类中)。这对我来说是一个惊喜,因为我期望这样一个内部的东西
首先,我使用的是 Visual Studio 2010,Measurement Studio 2010 plugin 、C# 和 .NET 4.0。 我的应用程序从 USB 设备接收数据,并使用 Wa
我正在尝试关注 this little tutorial ,但我不断收到此异常。 相关的 XAML 如下所示:
在对组件模型的影响方面是否存在任何实际差异: class MyComponent : Component { public MyComponent() { Initialize
我有一个简单的WPF页面,上面有几个radiobuttons,每个RadioButton均以检查事件处理程序注册,以便在更改选择时发生某些事情。默认情况下,我希望选择这些 RadioButtons 之
我在 StackOverflow 上检查了所有类似的问题,但没有一个答案能解决我的问题。我只是得到标题中的错误。 这是我的 MainVindow.xaml:
好的。这个有点傻。 我正在为 Access 数据库编写前端代码(我知道,重新发明轮子)。这个前端很简单。个人可以添加新条目或搜索现有条目。这两个都工作正常。该程序是 self 更新的,但非常简单。它比
我有部分公开课 namespace BugNetWPF { public partial class ReportScreen_IdRangeReport : Page {
使用 Suversion 和 WinDiff 分支/合并类项目和网络项目没有问题。 我永远无法合并的唯一一种项目是 winform 项目。 InitializeComponent 方法总是在仅进行少量
我正在尝试调用 InitializeComponent 方法,但出现以下错误: Type 'WindowsFormsApplication1.Form1' already defines a memb
当您在设计时修改 ListView 的列标题时,设计器会生成代码以在运行时序列化列标题: private void InitializeComponent() { this.listView1
我是一名优秀的程序员,十分优秀!