TFS Gotcha (Exception Handling)

Published on
1 minute read

When coding against team foundation server you must be aware that some of the exceptions thrown by Team Foundation Server  are not Serilisable! I think that this was an oversite by Microsoft, but it is there none the less.

An example of this is; TeamFoundationServerUnauthorizedException

If you want to handle this exception accross Windows Communication Foundation   you will need to create a custom exception of the same name and re-throw this accross your services.

<DataContract()> _
Public Class TeamFoundationServerUnauthorizedException

Public Sub New()
    …
  End Sub

End Class

Make sure that you mark it as a data contract and then you can throw it when you encounter the Team Foundation Server  exception:

Try
  ’ Team Foundation Server  Connection Code
Catch ex As TeamFoundationServerUnauthorizedException
  Throw New FaultException(Of FaultContracts.TeamFoundationServerUnauthorizedException)(New FaultContracts.TeamFoundationServerUnauthorizedException())
Catch ex As System.Exception
  Throw New FaultException(Of System.Exception)(ex, “Failed to do team server thing”, New FaultCode(" Team Foundation Server  :EH:S:0001"))
End Try

This will allow you to handle Team Foundation Server  exceptions for your Windows Communication Foundation  service application on the client.

Technorati Tags: ALM    TFS 

Software Development Technical Mastery Troubleshooting

Related blog posts

No related videos found.

Connect with Martin Hinshelwood

If you've made it this far, it's worth connecting with our principal consultant and coach, Martin Hinshelwood, for a 30-minute 'ask me anything' call.

Our Happy Clients​

We partner with businesses across diverse industries, including finance, insurance, healthcare, pharmaceuticals, technology, engineering, transportation, hospitality, entertainment, legal, government, and military sectors.​

Milliman Logo
Akaditi Logo
Alignment Healthcare Logo
Workday Logo
SuperControl Logo
Emerson Process Management Logo
Brandes Investment Partners L.P. Logo
Boxit Document Solutions Logo
Qualco Logo
Deliotte Logo

CR2

Schlumberger Logo
Slaughter and May Logo
Genus Breeding Ltd Logo
Flowmaster (a Mentor Graphics Company) Logo
Slicedbread Logo
Ericson Logo
Jack Links Logo
Royal Air Force Logo
Department of Work and Pensions (UK) Logo
Washington Department of Transport Logo
Nottingham County Council Logo
Washington Department of Enterprise Services Logo
New Hampshire Supreme Court Logo
Alignment Healthcare Logo
Genus Breeding Ltd Logo
Workday Logo
Lockheed Martin Logo
Qualco Logo
Jack Links Logo