直接搬的CSDN代码,用TabControl实现选项卡,但是自己做了两个进去,就报错了

直接搬的CSDN代码,用TabControl实现选项卡,但是自己做了两个进去,就报错了,详细:$exception {"创建窗口句柄时出错。"} System.ComponentModel.Win32Exception,看不懂,再找了一些解决办法,一直没成功。因为不会自己写,两次用的都是这套代码,结果只用一个还好好的,加上第二个,就报错了。
        //反射生成窗体Form fm = (Form)Assembly.GetExecutingAssembly().CreateInstance(form);
        //设置窗体没有边框,加入到选项卡中
        fm.FormBorderStyle = FormBorderStyle.None;
        fm.TopLevel = false;
        fm.Parent = ((TabControl)sender).SelectedTab;
        fm.ControlBox = false;
        fm.Dock = DockStyle.Fill;
        fm.Show();
        s[((TabControl)sender).SelectedIndex] = 1;
System.ComponentModel.Win32Exception

HResult=0x80004005
Message=创建窗口句柄时出错。
Source=System.Windows.Forms
StackTrace:
在 System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
在 System.Windows.Forms.Control.CreateHandle()
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.TabPage.set_Visible(Boolean value)
在 System.Windows.Forms.TabControl.UpdateTabSelection(Boolean updateFocus)
在 System.Windows.Forms.TabControl.OnHandleCreated(EventArgs e)
在 System.Windows.Forms.Control.WmCreate(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.TabControl.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

希望可以运行成功,一个选项卡打开一个界面后,可以用另外一个选项卡,在有其他界面可以选择