English 中文(简体)
我不能让空手道者来破坏我的C#计划吗?
原标题:I can t get nulls to crash my C# program?
  • 时间:2012-05-25 09:30:29
  •  标签:
  • c#
  • crash
  • null

好,所以我有一个奇怪的问题, 我多次搜索谷歌 寻找答案,但徒劳无益...不管怎样,我有一个问题, 在那里我似乎不能得到我的程序 显示我想要的错误信息。这已经发生很多次了, 并最终发现它的变量是无效的, 但出于某种原因, 没有错误被丢弃?

这里有一个例子,我刚刚有过。

点击按钮以显示名为调试的新窗体 。

Debug debug = new Debug();
debug.Show(this);

这是在我的调试形式。

public new void Show(IWin32Window owner)
{
    base.Show(owner);
    Parent.Move += new EventHandler(delegate(object sender, EventArgs e)
    {
        Location = new Point(Parent.Location.X + Parent.Width, Parent.Location.Y);
    });
}

长话短说,代码没有起作用,因为父母是无效的,但它甚至从未暗示这是问题所在。

我肯定有些解释 但我在谷歌搜索中还没有找到...

最佳回答

您也可以在视觉工作室中尝试以下内容:

  1. Debug > Exceptions
  2. Expand the "Common Language Runtime Exceptions" entry
  3. Expand the "System" entry
  4. Click the checkbox for System.NullReferenceException
  5. Click OK
  6. Run your application with the debugger attached.

现在,每当抛出NullReference例外,调试器就会破裂。

我想要么你的应用程序被包成一个试捕 要么在调用机底部某处 导致调试。Show () 被调用, 代码被包成一个试捕 捕捉

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签