Game Development Community

Got a problem when running "MissingMethodException was handled"

by kinleong · in Torque X 2D · 07/15/2009 (3:22 am) · 3 replies

Hi All,

I am new in Torque X 2D. I got a problem in this afternoon when I click debug in Visual Studio. It pointed out that the following code got an exception:

SceneLoader.Load(@"data\levels\gardenBumper.txscene");

It is in the BeginRun() method and I haven't changed it. The following is the error trace that copied from Visual Studio.



System.MissingMethodException was unhandled
Message="No parameterless constructor defined for this object."
Source="mscorlib"
StackTrace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at GarageGames.Torque.Core.Xml.TorqueXmlDeserializer._MakeNewObject(String typeName, Object& o, TypeInfo& t, Int32 childCount)
at GarageGames.Torque.Core.Xml.TorqueXmlDeserializer._SetFieldOrProperty(IFieldOrProperty fieldOrProperty, XmlNode element, Object& o)
at GarageGames.Torque.Core.Xml.TorqueXmlDeserializer._Recurse(XmlNode element, Object& o, TypeInfo ti)
at GarageGames.Torque.Core.Xml.TorqueXmlDeserializer._RecurseList(XmlNode element, DeserializedList& list, TypeInfo ti)
at GarageGames.Torque.Core.Xml.TorqueXmlDeserializer._SetFieldOrProperty(IFieldOrProperty fieldOrProperty, XmlNode element, Object& o)
at GarageGames.Torque.Core.Xml.TorqueXmlDeserializer._Recurse(XmlNode element, Object& o, TypeInfo ti)
at GarageGames.Torque.Core.Xml.TorqueXmlDeserializer._RecurseList(XmlNode element, DeserializedList& list, TypeInfo ti)
at GarageGames.Torque.Core.Xml.TorqueXmlDeserializer._SetFieldOrProperty(IFieldOrProperty fieldOrProperty, XmlNode element, Object& o)
at GarageGames.Torque.Core.Xml.TorqueXmlDeserializer._Recurse(XmlNode element, Object& o, TypeInfo ti)
at GarageGames.Torque.Core.Xml.TorqueXmlDeserializer.Process(String levelFile, Object target)
at GarageGames.Torque.Core.Xml.TorqueSceneData.Load(String filename, List`1 extraAssemblies)
at GarageGames.Torque.Core.Xml.TorqueSceneData.Load(String filename)
at GarageGames.Torque.GameUtil.SceneLoader.Load(String sceneFileName)
at StarterGame2D.Game.BeginRun() in C:\Users\777\Desktop\XNAAntiDrug\Garden Game\GardenBumper\GardenBumper\Game\Game.cs:line 70
at Microsoft.Xna.Framework.Game.Run()
at StarterGame2D.Game.Main() in C:\Users\777\Desktop\XNAAntiDrug\Garden Game\GardenBumper\GardenBumper\Game\Game.cs:line 51
InnerException:






Please have a look. Thanks a lot.

#1
07/15/2009 (8:19 am)
I want to take a guess and say that some component you're loading up from the level xml has parameters in its constructor and the builder can't handle creating it.
#2
07/15/2009 (8:42 am)
Yeah, you'll need to play detective a little bit for this; the problem will be in the txscene file somewhere. I hope you have the Pro version of TX so you can look at the source code, otherwise it'll be a lot tougher.

If you do, when the exception happens, while execution is still suspended look at the Call Stack window (under the Debug menu in Windows). Double-click the line for the method _MakeNewObject. When that is brought up, hover the cursor over typeName to see if that gives you a clue about where it was in the txscene file when this exception happened. You can also double-click other lines in the call stack to trace farther back to try to understand what was going on at that moment.

Also, you can try examining the txscene manually by opening it in VS. Look at the objects section. It probably won't be in the T2DCollisionMaterial or AnimationData's, so skip past those to the actual objects being created. Look at <ObjectType> and especially at <Components>. As David suggested, it may well have to do with a Component you created.
#3
07/17/2009 (8:38 pm)
Thanks David and Scott. Got the solution right now. It's really related to the level xml. When I did some adjustment in the TXB, it didn't update in the VS2008, so got the problem.