Sign in to follow this  

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

This topic is 4306 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
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

This topic is 4306 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this