locked
Custom checkin policy with UI component not shown in VS 2012 RRS feed

  • Question

  • I have rebuild my checkin policy for VS 2012, but the dialog, which should open in Evaluate()-Override is not shown. It seems to be a threading problem. How can I integrate my custom UI in the checkin-process in VS 2012?
    Thursday, August 16, 2012 2:09 PM

All replies

  • Hi Herwig,

    Thanks for your post!

    Evaluate() shouldn't display UI, Evaluate() should just create failures if there are any issues. So you shouldn’t ever show UI in a checkin policy.  They care evaluated asynchronously and often enough that the UI popping up would be very annoying.  The notion of checkin policies is that they evaluate a checkin and provide a message in the policy tab.  The user can then act on the entry in the policy tab to interact with checkin policy specific UI.

    For more information you can refer to http://social.msdn.microsoft.com/Forums/da-DK/tfsgeneral/thread/5e990d95-5514-4570-8efa-235ffbb89130

    Hope it helps!

    Best Regards,


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

    Friday, August 17, 2012 6:12 AM
    Moderator
  • Okay understood. Nevertheless in VS 2010 it worked for us this way. Our checkin policy forces the developer to enter working hours which calculates the completed and the remaing hours and generates a comment based on the selected work items which can be modified within the UI. So how should that custom UI integrated in VS 2012? Is there another extension possibility with documentation or samples how to integrate a UI component in the new pending changes UI component of Visual Studio? How to use the policy tab you mentioned?
    Friday, August 17, 2012 8:25 AM
  • Hi Herwig,

    Do you mean your customized check in policy with UI can work in VS 2010 instead of VS 2012?

    I am sorry I cannot take a try with it. However, you can upgrade your custom check-in policy to VS 2012 first, and see if it helps. Please refer to the following thread to see how to upgrade the custom check-in policy to VS 2012:

    http://social.msdn.microsoft.com/Forums/en-US/tfspowertools/thread/b9eccbe6-9424-44f8-8d89-8695d7f4499a

    Hope it helps!

    Best Regards,


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, August 21, 2012 6:27 AM
    Moderator
  • That's exactly what I did. The policy uses the Visual Studio 2012 assembly references, is correctly installed and the evaluate method is called within checkin procedure.

    Yes the same code showed a dialog in Visual Studi 2010.

    The error which is shown is:

    Internal error in MTM Standard Policy. The calling thread must be STA, because many UI components require this.

    The calling thread must be STA, because many UI components require this.

    Wednesday, August 22, 2012 9:10 AM
  • Hi Herwig,

    Thanks for your feedback!

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Thank you for your understanding and support.

    Best Regards, 


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, August 28, 2012 8:26 AM
    Moderator
  • Hi Herwig,

    Any chance you could pass along the code responsible for implementing the checkin policy? I'd definitely be interested in trying to reproduce this in-house. You can find my email address in my MSDN profile.

    Thanks,


    Ed Dore

    Friday, September 7, 2012 6:36 PM
  • I've used this kind of code in Evaluate() and it is displaying the UI:

    using (TestCheckinPolicy.Form1 f = new TestCheckinPolicy.Form1())
    {
                    f.Focus();
                    f.TopMost = true;
                    f.ShowDialog();
    
                    if (f.DialogResult != DialogResult.OK)
                    {
    		failures.Add(new PolicyFailure("you didnt hit OK", this));
    	}
    }


    Daniel



    • Edited by DS19 Friday, October 19, 2012 3:27 PM
    Friday, October 19, 2012 3:27 PM
  • Hi Herwig,

    I've got the same error message this weekend.
    You can try the attached code snippet:

    var thread = new Thread(GetAllRssNews); // call your internal method here
    thread.SetApartmentState(ApartmentState.STA);
    thread.IsBackground = true;
    thread.Start(feedUrl); // pass parameters here

    Source: http://www.biggle.de/blog/stathread-wpf

    Regards
    Nico
    • Proposed as answer by NicoOrschelMVP Sunday, December 9, 2012 5:31 PM
    Sunday, December 9, 2012 5:31 PM