我有这个代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ConsoleApplication2
{
class Program
{
static void Main(string args)
{
string TheFormText;
string TheFormName;
string TheFormTag;
Form activeForm = Form.ActiveForm;
TheFormText = activeForm.ActiveMdiChild.Text.ToString();
TheFormName = activeForm.ActiveMdiChild.Name.ToString();
try
{
TheFormTag = activeForm.ActiveMdiChild.Tag.ToString();
}
catch
{
TheFormTag = "<none>";
}
}
}
}
我尝试运行,但是当我运行时出现此错误 ConsoleApplication2.exe 中发生“System.NullReferenceException”类型的未处理异常
在 TheFormText = activeForm.ActiveMdiChild.Text.ToString();
有人可以帮我让它工作吗?