Dobrý den mam udělanou třídu: TridaDat, která v sobe obsahuje jeste další tridy. Vytvorim pole typu TridaDat a pak jej chci serializovat. v C# mi to fungovalo v pořádku ale potřebuji to ted dostat do VC++.
spadne mi to když chci uložit data, v tomto řádku :
XmlSerializer^ s = gcnew XmlSerializer (array<TridaDat^>::typeid);
Hlásí to tuto chybu :
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll
Additional information: Při reflexi typu došlo k chybě SerializaceDataToXml.TridaDat[].
zde je funkce pro uložení:
public:
static void SerializeToXML(array<TridaDat^>^ process, System::Windows::Forms::SaveFileDialog^ sfd)
{
XmlSerializer^ s = gcnew XmlSerializer (array<TridaDat^>::typeid);
TextWriter^ writer = gcnew StreamWriter (sfd->FileName);
s->Serialize (writer,process);
writer->Close();
}
třída kterou chci ukládat vypada takto a je napsana v TridaData.h:
#pragma once
using namespace System::IO;
using namespace System;
using namespace System::Xml;
using namespace System::Xml::Schema;
using namespace System::Xml::Serialization;
namespace SerializaceDataToXml
{
[Serializable] //serializační znak
ref class Cerpadlo
{
public:
Cerpadlo(){
DobaCerpani = gcnew array<double>(8);
PrutokCerpadla = gcnew array<int>(8);
}
bool PumpActive;
static array<double> ^ DobaCerpani;
static array<int> ^ PrutokCerpadla;
};// class Cerpadlo
[Serializable]
ref class Agilent
{
public:
Agilent(){
AgiNasVelicina1 = gcnew array<int>(8);
Hodnota1 = gcnew array<double>(8);
Hodnota2 = gcnew array<double>(8);
Hodnota3 = gcnew array<double>(8);
Mereno1 = gcnew array<int>(8);
CasBehu = gcnew array<double>(8);
OffHodnota = gcnew array<double>(8);
}
bool AgiAct;
static array<int> ^ AgiNasVelicina1;
static array<double> ^ Hodnota1;
static array<double> ^ Hodnota2;
static array<double> ^ Hodnota3;
static array<int> ^ Mereno1;
static array<double> ^ CasBehu;
static array<double> ^ OffHodnota;
};//class Agilent
[Serializable]
ref class Termostat
{
public:
Termostat(){
TermOn = gcnew array<bool>(8);
TermDobaOn = gcnew array<bool>(8);
TermTemp = gcnew array<int>(8);
TermDelay = gcnew array<int>(8);
}
static array<bool> ^ TermOn;
static array<bool> ^ TermDobaOn;
static array<int> ^ TermTemp;
static array<int> ^ TermDelay;
};
[Serializable]
ref class TGdrive
{
public:
TGdrive(){
Vzor = gcnew array<int>(24);
Funkce = gcnew array<int>(24);
Pozn = gcnew array<String^>(24);
}
static array<int> ^ Vzor;
static array<int> ^ Funkce;
static array<String^> ^ Pozn;
};
[Serializable]
public ref class TridaDat
{
public:
TridaDat(){
cerpadlo = gcnew Cerpadlo();
agilent = gcnew Agilent();
termostat = gcnew Termostat();
tgdrive = gcnew TGdrive();
}
String^ JmenoVzoru;
bool VzorAktivni;
String^ Komentar;
String^ PoleBunek;
Cerpadlo^ cerpadlo;
Agilent^ agilent;
Termostat^ termostat;
TGdrive^ tgdrive;
double MaxTlak;
int Tnas;
int Tods;
int Tvymyti;
};
}
moc děkuji za radu :)