Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8834443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:01:01+00:00 2026-06-14T09:01:01+00:00

I am writing a vs2012 extension that will talk to TFS 2010 (though I

  • 0

I am writing a vs2012 extension that will talk to TFS 2010 (though I would prefer if it could also work with tfs2012).

I need to invoke a compare operations on a file from the extension.

I want to use the default compare tool that is configured in visual studio at the moment of the innovation (because the user can configure a different compare tool).

I have the location of the file and I want to be able to invoke the following:

  • open the default compare.
  • open a compare with latest version
  • open a compare with workspace version
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:01:02+00:00Added an answer on June 14, 2026 at 9:01 am

    Use IVsDifferenceService to invoke Visual Studio diff tool from your VSPackage:

    private void Compare(string leftFile, string rightFile)
    {
        var diffService = (IVsDifferenceService)GetService(typeof(SVsDifferenceService));
        if (diffService != null)
        {
            ErrorHandler.ThrowOnFailure(
                diffService.OpenComparisonWindow(leftFile, rightFile).Show()
                );
        }
    }
    

    To test it you need to set the workspace and download the file you want to compare:

        // TODO: add some error handling
        var tpc = new TfsTeamProjectCollection(new Uri("http://tfs.company.com:8080/tfs"));
        var vcs = tpc.GetService<VersionControlServer>();
        var workspace = vcs.GetWorkspace(Environment.MachineName, vcs.AuthorizedUser);
    
        string localItem = @"C:\workspace\project\somefile.cs";
    
        var folder = workspace.GetWorkingFolderForLocalItem(localItem);
        var item = vcs.GetItem(folder.ServerItem, VersionSpec.Latest);
        var latestItem = string.Format("{0}~{1}", localItem, item.ChangesetId);
        item.DownloadFile(latestItem);
    
        Compare(localItem, latestItem);
    

    References:

    using Microsoft.VisualStudio;
    using Microsoft.VisualStudio.Shell;
    using Microsoft.VisualStudio.Shell.Interop;
    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.VersionControl.Client;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an extension for VS2010 that reorders a page of code by rearranging
Background I am writing code in VS 2010, .NET 4, C#. Also, in case
Writing htaccess that allows me to remove index.php from the URL can confuse search
Writing documentation in html requires some code examples. What to do with characters that
Say that I'm writing a test and my caret is here (indicated by |):
I am writing my first little Access 2003 application. I have two queries that
I am currently writing an application in VS2010 which will access many different SQL
I am using ssdt in VS2012. I am writing a stored procedure and now
I would like to write a plugin for Visual Studio 2010 but in fact
I'm writing an extension for VS2010, and my package implements IVsSelectionEvents to track the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.