Sign in to follow this  

XNA 4.0 IntermediateSerializer.Deserialize problem in List List

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

When I Deserialize, it break and show "TypeAccessException was unhandled" error as below:

Attempt by security transparent method 'DynamicClass.ReflectionEmitUtils(System.Object, System.Object)' to access security critical type 'UtilityWinGameLibrary.CellData' failed.

Assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.


Does somebody know how to resolve this problem?
My project is WinForm that saves and loads xml files. The xml files will use in my XNA game client. I wish I can use IntermediateSerializer, becuase game client can load xml(xnab) by conent manager.



public enum ENUM_CELL_TYPE
{
NONE = -1,
FIRE = 0,
GRASS = 1,
MUD = 2,
WATER = 3,
};

public enum ENUM_THING_TYPE
{
NONE = -1,
ROCK0 = 0,
TREASURE0 = 1,
}

[Serializable]
public class CellData
{
public CellData()
{
cellType = ENUM_CELL_TYPE.NONE;
dist = 0;
objectBase = null;
}

//public CellData(ENUM_CELL_TYPE _type)
//{
// cellType = _type;
// dist = 0;
// objectBase = null;
//}

public void SetCell(ENUM_CELL_TYPE _cellType)
{
cellType = _cellType;
}

public void SetThing(ENUM_THING_TYPE _thingType)
{
thingType = _thingType;
}

public void ClearStep()
{
dist = 0;
objectType &= ~ENUM_OBJECT_CATEGORY.MOVEDIST;
}

public bool ChkMove(int _dist)
{
return objectBase == null && objectType == ENUM_OBJECT_CATEGORY.NONE || ((objectType & ENUM_OBJECT_CATEGORY.MOVEDIST) == ENUM_OBJECT_CATEGORY.MOVEDIST) && (dist < _dist);
}

public ENUM_CELL_TYPE cellType;
public ENUM_THING_TYPE thingType;
public ENUM_OBJECT_CATEGORY objectType;
public int dist;

public ObjectBase objectBase;
}

public class SaveFloorData
{
public float hexWidth;
public Point size;

public List<List<CellData>> CellArray;
}

public bool LoadFloorFileIntermediate(string filename)
{
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreComments = true;

using (XmlReader reader = XmlReader.Create(filename, settings))
{
saveFloorData = IntermediateSerializer.Deserialize<SaveFloorData>(reader, null);//<===problem here
}

return true;
}






Share this post


Link to post
Share on other sites

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