本文介绍了对象引用未设置为object的实例:weifenluo的C ++ / cli中的dockpanel套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Dock Panel套件的新手

基本上我在从xml文件加载布局时遇到运行时错误。保存布局工作正常。

我有2个表格,第一个是主表格。第二种形式是儿童形式

I'm new to Dock Panel suite
Basically i'm having run time error when it comes to loading layout from xml file. saving layout works fine.
I have 2 forms, 1st one is main form. 2nd form is child form

public ref class MyForm2 : DockContent //2nd form (child form)


主要形式的
,我有以下代码


in main form, i have following code

private: IDockContent ^GetContentFromPersistString(System::String ^persistString)
{
    array<Char>^ id = { ',' };
    array<System::String^> ^parsedStrings = persistString->Split(id);

    if (parsedStrings->Length != 3)
    return nullptr;

    MyForm2 ^mf2 = gcnew MyForm2();
    if (parsedStrings[1] != System::String::Empty)
        mf2->Name = parsedStrings[1];
    if (parsedStrings[2] != System::String::Empty)
        mf2->Text = parsedStrings[2];
    return mf2;
}

private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
        System::String^ path = Path::Combine(Path::GetDirectoryName(Application::ExecutablePath), "DockPanel.config");
        DeserializeDockContent ^m_deserializeDockContent = gcnew DeserializeDockContent(GetContentFromPersistString);
            dockPanel1->LoadFromXml(path, m_deserializeDockContent); //Crashes here
        }







An unhandled exception of type 'System.NullReferenceException' occurred in WeifenLuo.WinFormsUI.Docking.dll

Additional information: Object reference not set to an instance of an object.





我使用示例代码(DockSample项目)



我尝试了什么:



使用FileStream ^ fs1 = gcnew FileStream(path,FileMode :: Open,FileAccess :: Read);

流^ s1 = fs1;而不是System :: String



I used this example code from C# (DockSample Project)

What I have tried:

using FileStream ^fs1 = gcnew FileStream(path, FileMode::Open,FileAccess::Read);
Stream ^s1 = fs1; instead of System::String

推荐答案


这篇关于对象引用未设置为object的实例:weifenluo的C ++ / cli中的dockpanel套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 09:56