Search code examples
vb.nettfstfs-sdk

Value of type 'Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer' cannot be converted to 'System.Type


I'm working on a custom TFS Build workflow based on the code found in two blogs:

When I implement the VB.Net code within my XAML workflow, I'm currently getting the following errors on build runtime:

The build process failed validation. Details:

Validation Error: The private implementation of activity '1: DynamicActivity' has the following validation error: Compiler error(s) encountered processing expression "TFSService".

Value of type 'Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer' cannot be converted to 'System.Type'.

Validation Error: The private implementation of activity '1: DynamicActivity' has the following validation error: Compiler error(s) encountered processing expression "TFS.GetService(Of VersionControlServer)();".

End of expression expected.

I've traced the error down to this section of code (Simplified from XAML):

TFS=Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory.GetTeamProjectCollectionFactory(New Uri("MyTeamsTFSServer"))
TFSService = TFS.GetService(Of VersionControlServer)()

I've tried changing the type of TFSService from both Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer and System.Type without success.

From what I can tell the error is occurring in the "Of VersionControlServer".

Has anyone ever encountered this? And if so how did you resolve it?


Solution

  • Turns out the issue was the URL I was using, I made a typo when I was entering it in. Yay for descriptive error messages...

    I found this while I was checking my authentication using the two methods:

    TFS.HasAuthenticated
    TFS.Authenticate();
    

    My code blew out when I was running the Authenticate() method.