Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Visual Studio扩展性:IChangeSet服务返回的值始终为空_C#_Visual Studio_Visual Studio Extensions - Fatal编程技术网

C# Visual Studio扩展性:IChangeSet服务返回的值始终为空

C# Visual Studio扩展性:IChangeSet服务返回的值始终为空,c#,visual-studio,visual-studio-extensions,C#,Visual Studio,Visual Studio Extensions,我正在尝试将Git支持添加到我的Visual Studio 2015扩展中。对于TFVC团队资源管理器页面,我的一切都正常工作,现在我正在尝试让我的扩展显示在Git更改和Git历史页面上。为了能够在Git changes页面上检测到挂起的更改,我需要获得IChangesExt服务的句柄,但由于某种原因,它对我不起作用;我总是返回一个空值,而不是预期的IChangeSet实例 以下是该站点的相关代码片段: Microsoft.TeamFoundation.Controls.ITeamExplore

我正在尝试将Git支持添加到我的Visual Studio 2015扩展中。对于TFVC团队资源管理器页面,我的一切都正常工作,现在我正在尝试让我的扩展显示在Git更改和Git历史页面上。为了能够在Git changes页面上检测到挂起的更改,我需要获得IChangesExt服务的句柄,但由于某种原因,它对我不起作用;我总是返回一个空值,而不是预期的IChangeSet实例

以下是该站点的相关代码片段:

Microsoft.TeamFoundation.Controls.ITeamExplorer teamExplorer;
teamExplorer = base.GetService(typeof(Microsoft.TeamFoundation.Controls.ITeamExplorer)) as Microsoft.TeamFoundation.Controls.ITeamExplorer;

Microsoft.TeamFoundation.Controls.ITeamExplorerPage teamExplorerPage;
Microsoft.TeamFoundation.Git.Controls.Extensibility.IChangesExt changesExt;

teamExplorerPage = teamExplorer.NavigateToPage(new Guid(pageGuid), null);
changesExt = teamExplorerPage.GetExtensibilityService(typeof(Microsoft.TeamFoundation.Git.Controls.Extensibility.IChangesExt)) as Microsoft.TeamFoundation.Git.Controls.Extensibility.IChangesExt;
我的代码略有不同,因为我的代码在Git Changes窗口打开时自动执行,所以我不需要执行teamExplorer.NavigateToPage()调用。相反,我使用teamExplorer.CurrentPage,我可以在调试器中看到它实际上是Git Changes页面(GitPendingChangesPageVS是类型),因此我应该在站点中进行与示例中相同的调用。下面是我在Git Changes页面的Loaded()函数中的代码。请注意,我尝试以4种不同的方式获取IChangesExt服务,但它们都返回null

public override void Loaded(object sender, SectionLoadedEventArgs e)
{
    base.Loaded(sender, e);

    // Find the Pending Changes extensibility service and save a handle to it.
    var service = this.GetService<IChangesExt>();

    var teamExplorer = this.GetService<ITeamExplorer>();
    var service2 = teamExplorer.GetService(typeof(IChangesExt)) as IChangesExt;
    var service3 = teamExplorer.CurrentPage.GetExtensibilityService(typeof(IChangesExt)) as IChangesExt;
    var service4 = teamExplorer.CurrentPage.GetService<IChangesExt>();
...
}
public override void Loaded(对象发送方,SectionLoadedEventArgs e)
{
基本。已加载(发送方,e);
//查找挂起的更改扩展性服务并保存其句柄。
var service=this.GetService();
var teamExplorer=this.GetService();
var service2=teamExplorer.GetService(typeof(IChangesExt))作为IChangesExt;
var service3=teamExplorer.CurrentPage.GetExtensibilityService(typeof(IChangesExt))作为IChangesExt;
var service4=teamExplorer.CurrentPage.GetService();
...
}
你知道我做错了什么吗

该扩展是开源的,因此如果您喜欢,可以(确保获得GitInitialFunctionality分支)查看一下。相关代码位于GitChangesSection.cs文件中

我也发了帖子,希望经常访问这些论坛的人能帮助我


如有任何建议,我们将不胜感激。谢谢

我找到了问题的根源。我只是注意到在VS 2013中一切都很好,但在VS 2015中却没有。在检查我的引用之后,我看到我的VS 2015项目引用了2013(v12.0)Microsoft.TeamFoundation.Git.Controls.dll,它是包含iChangesXT接口的程序集。我将VS 2015(v14.0)版本的dll添加到我的解决方案中,并更改了VS 2015项目以引用它,现在它正按预期工作:)

我找到了问题的根源。我只是注意到在VS 2013中一切都很好,但在VS 2015中却没有。在检查我的引用之后,我看到我的VS 2015项目引用了2013(v12.0)Microsoft.TeamFoundation.Git.Controls.dll,它是包含iChangesXT接口的程序集。我在解决方案中添加了VS 2015(v14.0)版本的dll,并更改了VS 2015项目以引用它,现在它正在按预期工作:)

我可以问你从哪里得到Microsoft.TeamFoundation.Controls.dll吗?我只是在我的C驱动器上快速搜索了一下,在GAC中找到了它,地址是
C:\Windows\Microsoft.NET\assembly\GAC\U MSIL\Microsoft.TeamFoundation.Controls\v4.0\u 12.0.0.0\u b03f5f7f11d50a3a\Microsoft.TeamFoundation.Controls.dll
。GAC中有几个不同的版本,所以请确保您得到了正确的版本。如果你想问Microsoft.TeamFoundation.Git.Controls.dll在哪里,我记不得了,但是你可以从我能问一下你从哪里得到Microsoft.TeamFoundation.Controls.dll吗?我只是在我的C驱动器上快速搜索了一下,在GAC中找到了它,地址是
C:\Windows\Microsoft.NET\assembly\GAC\U MSIL\Microsoft.TeamFoundation.Controls\v4.0\u 12.0.0\u b03f5f7f11d50a3a\Microsoft.TeamFoundation.Controls.dll
。GAC中有几个不同的版本,所以请确保您得到了正确的版本。如果你想问Microsoft.TeamFoundation.Git.Controls.dll在哪里,我不记得了,但你可以从