locked
PInvokeStackImbalance was detected RRS feed

  • Question

  • Hi,

    I am new to DSL and just downloaded the SDK to learn it. I was following the guide as illustrated in http://msdn.microsoft.com/en-us/library/ee943825.aspx. When I followed the instructions in the "Running the DSL" section, VS failed on Step 3 with the following error message:

    PInvokeStackImbalance was detected

    Message: A call to PInvoke function 'System.Windows!MS.Internal.XcpImports::SetFrameworkCallbacksNative' 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.

    Visual Studio debugger breaks at:

    		protected virtual bool SelectedToolboxItemSupportsFilterString(DslDiagrams::DiagramView activeView, string filter)
    		{
    			return activeView.SelectedToolboxItemSupportsFilterString(filter);
    		}

    in the Diagram.cs file.

    I am currently running Visual Studio 2010 Ultimate SP1 on a Windows Server 2008 R2 SP1 (x64). I would like to know if anyone can help me resolve the issue.

    Thank You 

    Hugs,
    Serena 

     

    Friday, November 25, 2011 1:31 AM

Answers

  • Serena,

    It isn't a problem with your DSL; it's a problem with another component that is providing a toolbox item.

    The issue appears when debugging DSLs because when you start a debugging session, a new instance of Visual Studio is launched and the toolbox is reset. This causes a lot of components that are not related to your DSL to be re-initialised, and it is one of them that is causing the problem.

    The message is just a warning so you can just click "continue" (although you will have to click it multiple times are there are a large number of similar warnings!).

    You can stop that warning from appearing by doing the following:

    * Select the menu item "Debug", "Exceptions". The Exceptions dialogue will appear.
    * Click on "Find..."
    * Search for "PInvokeStackImbalance" and uncheck the "Thrown" checkbox.


    Regards,
    Duncan

    Monday, November 28, 2011 10:26 AM

All replies

  • Wow. I have never seen that error before.

    Try this:

    • Delete this folder:
      C:\Users\{you}\AppData\Local\Microsoft\VisualStudio\10.0Exp
    • On the Windows Start menu, choose All Programs, Microsoft VIsual Studio SDK, Tools, Reset the Visual Studio Experimental Instance
    • Open your DSL solution
    • On the Visual Studio Build menu, choose Rebuild All
    • Then Debug>Run

    Hope that works.

     


    - Alan -MSFT
    Sunday, November 27, 2011 5:16 PM
  • Hi Alan,

    I tried what you suggested. Recreated the project as well. Still getting the same error. :(

    Is there anything wrong in running the DSL on 64 bit machines? 

    http://msdn.microsoft.com/en-us/library/0htdy0k3.aspx

    Hugs,
    Serena 

    Monday, November 28, 2011 1:41 AM
  • Serena,

    It isn't a problem with your DSL; it's a problem with another component that is providing a toolbox item.

    The issue appears when debugging DSLs because when you start a debugging session, a new instance of Visual Studio is launched and the toolbox is reset. This causes a lot of components that are not related to your DSL to be re-initialised, and it is one of them that is causing the problem.

    The message is just a warning so you can just click "continue" (although you will have to click it multiple times are there are a large number of similar warnings!).

    You can stop that warning from appearing by doing the following:

    * Select the menu item "Debug", "Exceptions". The Exceptions dialogue will appear.
    * Click on "Find..."
    * Search for "PInvokeStackImbalance" and uncheck the "Thrown" checkbox.


    Regards,
    Duncan

    Monday, November 28, 2011 10:26 AM
  • Hi Duncan,

    Although I don't really like the workaround but I guessed it will be the closest to solve the problem now. I actually virtualized another Dev Box just to try out the DSL and the problem doesn't exist on a clean box. So that's good :)

    Thanks for the help!

    Hugs,
    Serena

    Sunday, December 11, 2011 5:26 AM
  • Hi Serena,

    Whether the problem repros or not depends on which SKU you have installed. If I remember correctly, the problem is due a designer related to Silverlight development. If the SKU you have installed doesn't include that designer, you won't see the issue.

    Regards,

    Duncan

    Monday, December 12, 2011 3:50 PM