Debugging Content Extension ContentTypeReader...

Pretty basic Q : How does one go about stepping through custom ContentTypeReader code???

Is it possible to step into Content.Load calls from the main application into the Custom extension project?

I’ve set breakpoints in the extension project, and launching the debugger only opens the MCGB tool ( which only allows you to drill-down in the writer portion of the extension ).

Any help is appreciated!

Make sure you reference the project with the extension (not the dll). Then you should be able to set breakpoints and step through when running Content.Load.

Hi!

Thanks for the response. I have the reference set properly. The issue is that calls to Content.Load are failing before the actual execution of the ::Read override.

I create a constructor, which is hit. I’ve also overriden ContentTypeReader::Initialize, and everything looks valid there. For some reason, the extension fails prior to ::Read being called.

Error details :
System.InvalidCastException was unhandled
HResult=-2147467262
Message=Specified cast is not valid.
Source=MonoGame.Framework
StackTrace:
at Microsoft.Xna.Framework.Content.ContentTypeReader1.Read(ContentReader input, Object existingInstance) at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance) at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T](T existingInstance) at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]() at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]() at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action1 recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
at CODENAME_CCF.Game1…ctor() in C:\Users\josia\OneDrive\Project\CODENAME_CCF\Game1.cs:line 29
at CODENAME_CCF.Program.Main() in C:\Users\josia\OneDrive\Project\CODENAME_CCF\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Quick update : For some reason, the default ::Read is being called ( protected override object Read(ContentReader input, object existingInstance) ), instead of the properly typed one. After stepping through, it executes, and reads the asset properly. However, I am still getting Specified cast is not valid., and the asset is not successfully loaded ( Content.Load still fails ).

Strangely enough, Content.Load[object] works. I am sure this has to do with the ::GetRuntimeReader, but I don’t see anything wrong there either…

Any ideas?!?!?