Jump to content
  • Advertisement
Sign in to follow this  
PumpkinPieman

[.net] An unhandled exception of type 'SerializationException'

This topic is 4525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, I've been trying to write an object data to a file for 3 hours ... I'm pretty much at my whits end. An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll Additional information: The type $ArrayType$0x7b463bb7 in Assembly LSpriteEdit, Version=1.0.2250.26616, Culture=neutral, PublicKeyToken=null is not marked as serializable.
#define SStringToString(s) (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(s)
#using <mscorlib.dll>
#using <system.dll>
#using <system.runtime.serialization.formatters.soap.dll>
#include <tchar.h>
#include <map>

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;
using namespace System::Runtime::Serialization;
using namespace System::Runtime::Serialization::Formatters::Binary;


[Serializable]  __gc class LSF_SPRITEFILE : public System::Object
{
public:
	BYTE	filetype __nogc [3];
	BYTE	version;
	BYTE	filename __nogc [80];
};

[Serializable]  __gc class LSF_TEXTUREMASK : public System::Object
{
public:
	BYTE	name __nogc [30];
	float	x __nogc [2];
	float	y __nogc [2];

public:
	System::String __gc *ToString(void){

		return S"";
	}
};

[Serializable]  __gc class LSF_FRAMESET : public System::Object
{
public:
	BYTE animationSetName __nogc [30];
	DWORD numberFrames;

public:
	System::String __gc *ToString(void){

		return S"";
	}
};

[Serializable]  __gc class LSF_FRAMEINFO : public System::Object
{
public:
	DWORD frameNum;
	BYTE	maskName __nogc [30];
	float	position __nogc [2];
	float	scale __nogc [2];
	float	centre __nogc [2];
	float	rotation;
	DWORD	diffuse;
	DWORD duration;
	float	depth;

public:
	System::String __gc *ToString(void){

		return S"";
	}
};




bool SpriteModel::saveFile(System::String* filename)
{
	Stream* stream = File::Open(filename, FileMode::Create);
	BinaryFormatter* bf = new BinaryFormatter();
	LSF_TEXTUREMASK*tm = new LSF_TEXTUREMASK;

	tm->x[0] = 10;
	tm->x[1] = 5;
	tm->y[0] = 10;
	tm->y[1] = 5;

	bf->Serialize(stream, tm);

	return false;
}




No matter what I do it throws an exception // lessbread edit - go easy on the long titles! // PumpkinPieman edit - I would if I wasn't so ticked off ... [Edited by - PumpkinPieman on February 28, 2006 2:34:56 PM]

Share this post


Link to post
Share on other sites
Advertisement
The .NET serializer doesn't know what to do with your unmanaged arrays in the LSF_TEXTUREMASK type. Either make them managed arrays or use another mechanism instead of serialization.

Share this post


Link to post
Share on other sites
I assumed that since they were static that I wouldn't have to delete them if the object was going to be deleted anyway. I'm new to .NET so I'm guessing I made the wrong assumption...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!