Visual Studio Extension for Getting Pending Files for TFS

One07k-4914 101 Reputation points
2023-02-23T14:59:38.6533333+00:00

Capture.JPGHi All,

I am trying to create an extension (vSix) for VS2022. The idea is to get all the pending file details and forward them to some other tools. I am unable to resolve the problem. If anyone has a suggestion, then please let me know.

I had created the extension for VS2019 and its working. But for VS2022 its not working.

Thanks in Advance.

Exception:

System.ComponentModel.Composition.CompositionContractMismatchException: Cannot cast the underlying exported value of type 'Microsoft.VisualStudio.Composition.NetFxAdapters+MefV1ExportProvider+ComposablePartForExportFactory' to type 'Microsoft.TeamFoundation.Controls.ITeamExplorerSection'.
   at System.ComponentModel.Composition.ExportServices.CastExportedValue[T](ICompositionElement element, Object exportedValue)
   at System.ComponentModel.Composition.ReflectionModel.ExportFactoryCreator.LifetimeContext.GetExportLifetimeContextFromExport[T](Export export)
   at System.ComponentModel.Composition.ExportFactory`1.CreateExport()
   at Microsoft.TeamFoundation.Controls.WPF.TeamExplorer.Framework.TeamExplorerSectionHost.Create()
using Microsoft.TeamFoundation.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VSIXProject1
{ 
    [TeamExplorerSection("C406700D-28E8-4955-8885-4D98D4D49C10", TeamExplorerPageIds.PendingChanges, 35)]
    public class FindPendingChanges : Microsoft.TeamFoundation.Controls.ITeamExplorerSection
    {
        public string Title => throw new NotImplementedException();
        private IServiceProvider ServiceProvider { get; set; }

        public object SectionContent => throw new NotImplementedException();

        public bool IsVisible { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
        public bool IsExpanded { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

        public bool IsBusy => throw new NotImplementedException();

        public event PropertyChangedEventHandler PropertyChanged;

        event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
        {
            add
            {
                throw new NotImplementedException();
            }

            remove
            {
                throw new NotImplementedException();
            }
        }

        public void Initialize(object sender, SectionInitializeEventArgs e)
        {
            System.Diagnostics.Debugger.Launch();
            ServiceProvider = e.ServiceProvider;
            if (!(ServiceProvider.GetService(typeof(ITeamExplorer)) is ITeamExplorer teamExplorer))
            {

            }
        }
        public void Cancel()
        {
            throw new NotImplementedException();
        }

        public void Dispose()
        {
            throw new NotImplementedException();
        }

        public object GetExtensibilityService(Type serviceType)
        {
            throw new NotImplementedException();
        }



        public void Loaded(object sender, SectionLoadedEventArgs e)
        {
            throw new NotImplementedException();
        }

        public void Refresh()
        {
            throw new NotImplementedException();
        }

        public void SaveContext(object sender, SectionSaveContextEventArgs e)
        {
            throw new NotImplementedException();
        }

     
    }
}


<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
    <Metadata>
        <Identity Id="VSIXProject1.24da91b7-bb83-436f-9613-e0bc24223cc1" Version="1.0" Language="en-US" Publisher="XYZ" />
        <DisplayName>VSIXProject1</DisplayName>
        <Description>Empty VSIX Project.</Description>
    </Metadata>
    <Installation>
        <InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0,18.0)">
            <ProductArchitecture>x86</ProductArchitecture>
        </InstallationTarget>
    </Installation>
    <Dependencies>
        <Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
    </Dependencies>
    <Prerequisites>
        <Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[17.0,18.0)" DisplayName="Visual Studio core editor" />
    </Prerequisites>
</PackageManifest>


Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,716 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,656 questions
Visual Studio Extensions
Visual Studio Extensions
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Extensions: A program or program module that adds functionality to or extends the effectiveness of a program.
194 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 29,606 Reputation points Microsoft Vendor
    2023-02-24T09:54:30.52+00:00

    Hello @One07k-4914 ,

    Welcome to Microsoft Q&A forum.

    Did you include the 2019 TFS assemblies but maybe didn’t change to use/install those for 2022?

    Please try to re-add the TFS related assemblies, and test again.

    See if this similar thread: CompositionContractMismatchException in VS 2015 Extension implementing ITeamExplorerSection helps.

    Best Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful