Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.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# 执行TfvcClient的CreateChangesetAsync时出现“不允许方法”异常_C#_.net_.net 4.5 - Fatal编程技术网

C# 执行TfvcClient的CreateChangesetAsync时出现“不允许方法”异常

C# 执行TfvcClient的CreateChangesetAsync时出现“不允许方法”异常,c#,.net,.net-4.5,C#,.net,.net 4.5,我在一家相当大的公司工作,我们面临一个问题,因为我们需要迁移一个解决方案 总而言之,我们有一个内部工具,可以浏览或使用旧的TFS 2013服务器,并解析几个csproj和配置文件,以更新其中的一些内容,从而能够将我们的站点迁移到IIS10 以前的解决方案使用NuGet软件包Machado.Microsoft.TeamFoundation和Machado.Microsoft.TeamFoundation.client,现在已经过时,无法正常工作 决定将我们的解决方案迁移到Microsoft.Tea

我在一家相当大的公司工作,我们面临一个问题,因为我们需要迁移一个解决方案

总而言之,我们有一个内部工具,可以浏览或使用旧的TFS 2013服务器,并解析几个csproj和配置文件,以更新其中的一些内容,从而能够将我们的站点迁移到IIS10

以前的解决方案使用NuGet软件包Machado.Microsoft.TeamFoundation和Machado.Microsoft.TeamFoundation.client,现在已经过时,无法正常工作

决定将我们的解决方案迁移到Microsoft.TeamFoundation NuGet软件包。一切都很顺利,而不是办理登机手续

private TfvcChangesetRef Checkin(TfvcItem item, string newContent)
{
    // Establish a connection using Windows Credentials
    using (var connection = TfsHelper.GetConnection())
    // Create TFS Client
    using (var tfvcClient = connection.GetClient<TfvcHttpClient>())
    {
        item.ContentMetadata = new FileContentMetadata();

        var changeset = new TfvcChangeset();
        var tfvcChange = new TfvcChange(item, versionControlChangeType.Edit);
        tfvcChange.NewContent = new ItemContent();
        tfvcChange.NewContent.Content = newContent;
        tfvcChange.NewContent.ContentType = ItemContentType.RawText;
        tfvcChange.Item.Path = item.Path;

        var changesList = new List<TfvcChange>();
        changesList.Add(tfvcChange);
        changeset.Author = new IdentityRef();
        changeset.Changes = changesList;
        changeset.Comment = "This is a test";

        return tfvcClient.CreateChangesetAsync(changeset).Result;
    }
}
调用tfvcClient.CreateChangesetAsyncchangeset时,应用程序正在中断,更改集由以下内容组成:

Changes          Count = 1 (Correct, one change to be checked in)
Comment          "This is a test"
Author           typeof(IdentifyRef)
Other values     Default ones.
引发的异常是:

System.AggregateException: 'One or more errors occurred.'
InnerException: VssServiceResponseException: Method Not Allowed

StackTrace of innerException:
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<HandleResponseAsync>d__52.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__50.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__47`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__28`1.MoveNext()
我们已经检查并实施了一些在互联网上找到的解决方案,但目前没有任何效果。你知道什么是错的或遗漏了什么吗


感谢您使用TFS 2013库中的SOAP对象模型;TFS 2013不完全支持REST客户端使用的REST API

System.AggregateException: 'One or more errors occurred.'
InnerException: VssServiceResponseException: Method Not Allowed

StackTrace of innerException:
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<HandleResponseAsync>d__52.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__50.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__47`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__28`1.MoveNext()