PInvokeStackImbalance was detected when manually running Xna Content pipeline

Posted by Miau on Stack Overflow See other posts from Stack Overflow or by Miau
Published on 2012-09-17T21:35:58Z Indexed on 2012/09/17 21:37 UTC
Read the original article Hit count: 456

Filed under:

So I m running this code

    static readonly string[] PipelineAssemblies =
        {
            "Microsoft.Xna.Framework.Content.Pipeline.FBXImporter" + XnaVersion,
            "Microsoft.Xna.Framework.Content.Pipeline.XImporter" + XnaVersion,
            "Microsoft.Xna.Framework.Content.Pipeline.TextureImporter" + XnaVersion,
            "Microsoft.Xna.Framework.Content.Pipeline.EffectImporter" + XnaVersion,
            "Microsoft.Xna.Framework.Content.Pipeline.XImporter" + XnaVersion,
            "Microsoft.Xna.Framework.Content.Pipeline.AudioImporters" + XnaVersion,
            "Microsoft.Xna.Framework.Content.Pipeline.VideoImporters" + XnaVersion,

        };

more code in between .....

        // Register any custom importers or processors.
        foreach (string pipelineAssembly in PipelineAssemblies)
        {
            _buildProject.AddItem("Reference", pipelineAssembly);
        }

more code in between .....

        var execute = Task.Factory.StartNew(() => submission.ExecuteAsync(null, null), cancellationTokenSource.Token);
        var endBuild = execute.ContinueWith(ant => BuildManager.DefaultBuildManager.EndBuild());

        endBuild.Wait();

Basically trying to build the content project with code ... this works well if you remove XImporter, AudioIMporters and VideoImporters but with those I get the following error:

PInvokeStackImbalance was detected Message: A call to PInvoke function 'Microsoft.Xna.Framework.Content.Pipeline!Microsoft.Xna.Framework.Content.Pipeline.UnsafeNativeMethods+AudioHelper::GetFormatSize' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Things I've tried:

  1. turn unsafe code on
  2. adding a lot of logging (the dll is found in case you are wondering)
  3. different wav and Mp3 files (just in case)

Will update...

© Stack Overflow or respective owner

Related posts about XNA