Exception calling SessionManager.CurrentSession.CreatePlayerAgent<> on Xbox 360

Nov 20, 2011 at 6:26 PM

I'm working on my own game, using the Ace on Steroids tutorial as a guide for how to do the basic setup.

Everything works fine when I run on Windows, but I've been trying to run it on my Xbox 360 with no success.  In my GamePlayGameState class, I get an exception thrown when it reaches the line:

_player = SessionManager.CurrentSession.CreatePlayerAgent<Player>(SessionManager.CurrentSession.LocalPlayers[0]);

The message is:  An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

SessionManager is not null, nor is CurrentSession, and LocalPlayers[0] seems to be identified correctly.

The callstack is:

 	mscorlib.dll!System.Reflection.RuntimeConstructorInfo.InternalInvoke(object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture, ref System.Threading.StackCrawlMark stackMark) + 0x114 bytes	
 	mscorlib.dll!System.Activator.InternalCreateInstance(System.Type type, bool nonPublic, ref System.Threading.StackCrawlMark stackMark) + 0xaf bytes	
 	mscorlib.dll!System.Activator.CreateInstance() + 0xc bytes	
 	Indiefreaks.Game.Logic.dll!Indiefreaks.Xna.Sessions.Session.CreatePlayerAgent(Indiefreaks.Xna.Sessions.IdentifiedPlayer identifiedPlayer) + 0x14 bytes	
>	AvatarAdventure.exe!AvatarAdventure.GameplayGameState.Initialize() Line 39 + 0x16 bytes	C#
 	Indiefreaks.Game.Framework.dll!Indiefreaks.Xna.Core.Application.LoadGameState(Indiefreaks.Xna.Core.GameState gameState, Indiefreaks.Xna.Core.LoadingGameState loadingGameState) + 0xa7 bytes	
 	Indiefreaks.Game.Framework.dll!Indiefreaks.Xna.Core.Application.LoadGameState(Indiefreaks.Xna.Core.GameState gameState) + 0x8 bytes	
 	AvatarAdventure.exe!AvatarAdventure.MainMenuGameState.OnSessionStarted(object sender, System.EventArgs e) Line 46 + 0x1b bytes	C#
 	Indiefreaks.Game.Logic.dll!Indiefreaks.Xna.Sessions.Session.OnSessionStarted() + 0x19 bytes	
 	Indiefreaks.Game.Logic.dll!Indiefreaks.Xna.Sessions.Local.LocalSession.Update(Microsoft.Xna.Framework.GameTime gameTime) + 0x23 bytes	
 	Indiefreaks.Game.Logic.dll!Indiefreaks.Xna.Sessions.Session.Indiefreaks.Xna.Core.IUpdate.Update(Microsoft.Xna.Framework.GameTime gameTime) + 0x114 bytes	
 	Indiefreaks.Game.Logic.dll!Indiefreaks.Xna.Sessions.SessionManager.Update(Microsoft.Xna.Framework.GameTime gameTime) + 0x18f bytes	
 	SynapseGaming-SunBurn-Pro.dll!SynapseGaming.LightingSystem.Core.SceneInterface.Update(Microsoft.Xna.Framework.GameTime gameTime) + 0x2e bytes	
 	Indiefreaks.Game.Framework.dll!Indiefreaks.Xna.Core.GameState.Indiefreaks.Xna.Core.IUpdate.Update(Microsoft.Xna.Framework.GameTime gameTime) + 0xc bytes	
 	Indiefreaks.Game.Framework.dll!Indiefreaks.Xna.Core.Application.Update(Microsoft.Xna.Framework.GameTime gameTime) + 0x70 bytes	
 	Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.Tick() + 0x27a bytes	
 	Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.HostIdle(object sender, System.EventArgs e) + 0x6 bytes	
 	Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.GameHost.OnIdle() + 0x19 bytes	
 	Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.XboxGameHost.RunOneFrame() + 0xc bytes	
 	Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.XboxGameHost.Run() + 0x1b bytes	
 	Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.RunGame(bool useBlockingRun) + 0x9c bytes	
 	Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.Run() + 0x7 bytes	
 	AvatarAdventure.exe!AvatarAdventure.Boot.Main() Line 23 + 0x6 bytes	C#

The Output window shows:

A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.Xna.Framework.GamerServices.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

I'm currently using the v0.8.x binaries, so that's as far as I can go with debugging it.  I'll switch to using the source code at some point in the near future so that I can provide more useful information.

Any assistance would be much appreciated!  So far I'm only looking at wireframe Avatars on my PC, and I'm itching to see them in their Sunburn-rendered glory. :-)

Nov 20, 2011 at 7:39 PM

Okay, never mind THAT.  Looks like I missed adding the GamerServicesComponent when I ported my code over to the IGF structure.  Does IGF have any functionality that wraps around GamerServicesComponent, or should I just use it as I would in standard XNA?

Of course, it's still crashing... now i just see this in the output window:

A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll

And it doesn't give me a call stack or break into a line of code anywhere.  Arrgh.  Guess I need to start commenting stuff out and running on Xbox until I can track it down. 

 

I really wish that Microsoft had made it simpler to develop Avatar games on Windows, rather than having to run a substantial amount of separate code for each platform.

Coordinator
Nov 20, 2011 at 11:14 PM

Hi TeagansDad,

If you want to develop an Avatar based game, you should definitivelly use the LiveSessionManager instead of the LocalSessionManager used within the Ace on Steroids tutorials: the LiveSessionManager wraps the GamerServicesDispatcher (no need to add the GamerServicesComponent therefore).
This network implementation will add Xbox Live support.

If you're still seeing exceptions like the KeyNotFoundException, I'd need some more details to help you out.

Nov 21, 2011 at 1:17 AM

Thanks, I'll give the LiveSessionManager a shot.  Does it work okay on Windows, or do I need to use conditionals to run the LocalSessionManager on Windows?

I think that the KeyNotFoundException errors might have come from one block of code that I missed putting #if WINDOWS around when I re-worked it into my IGF version. 

Coordinator
Nov 21, 2011 at 10:37 AM

The LiveSessionManager as the exact same requirements as when you'd use Xbox Live GamerServicesComponent thus Windows is supported but solely on development.

So, if you want to make a Windows release, you'd like to use a build condition to use LocalSessionManager on Windows.

However, this condition should only be needed when you create the SessionManager instance because it is meant to be abstract for your code. You'll then only have to set in your Application.InitializeSunBurn() override:

#if XBOX
SunBurn.AddManager(new LiveSessionManager(...));
#else
SunBurn.AddManager(new LocalSessionManager(...));
#endif

Note that one of the main differences between Live and Local SessionManagers is that the LocalSessionManager is only meant to be used for a SinglePlayer game.

When you need to access the session manager instance, you'll then be able to use one of the below methods:

// using the SunBurn SceneInterface GetManager method
// it'll work with any of the supported network implementations
var sessionManager = Application.SunBurn.GetManager<ISessionManager>(true);

// or to access the current session
var myPlayer = SessionManager.CurrentSession.CreatePlayerAgent(...);

However, as soon as I'll get the Lidgren network library implementation ready, you should be able to have single & multiplayer SessionManager replacing the LocalSessionManager by:

SunBurn.AddManager(new LidgrenSessionManager(...));

 

 

Nov 28, 2011 at 5:07 AM

Thanks for your help!  I haven't had a chance to try this out on the Xbox yet.

I'm re-thinking the whole use of Avatars though.  I wanted to go that route because I thought that it would save time and effort to have a player character which has a professional quality model and an existing library of animations. 

It's just enough different from using a skinned model to make things difficult, and I think I've spent almost as much time customizing the Avatar Wrapper as it would have taken me to make a prototype character model of my own.

I think I need to simply even more for my first game.  I mean, I'm not a rookie to software development (almost 10 years of desktop/web app development), and I've worked on two AAA studio games (Test Engineer on EA's skate, and Designer on Max Payne 3), but I've never made a complete game on my own.  So even knowing how much work is involved, I think I'm still underestimating how long things will take me...

Coordinator
Nov 28, 2011 at 11:03 AM

You're right! Making a full game on your own is really tedious and asks a lot of time and effort.

Be very careful on your specific case, I know that when working on a game after participating on AAA games, you put your game expectations very high.
I would suggest you to go straight to what the core features of your game and don't matter much on graphics first. Use placeholders and the easiest to implement and use assets and code. Once you get to a satisfactory game logic implementation, move on with graphics improvement.

Doing so, you'll end up working first on what is really important in a game: the game design. And it may save you time because you may find out that the initial game idea was not that good, needs to be thought back or too hard to make on your own.
Graphics with SunBurn for instance is now really easier than before, it is just very time consuming to have it right and pretty.

But at the end, it's up to you to find out what is the best for your specific case ;)