a·gen·tic a·gil·i·ty

TFS Gotcha (Exception Handling)

Explains how to handle non-serialisable Team Foundation Server exceptions in WCF by creating custom serialisable exceptions for reliable cross-service error handling.

Published on
1 minute read
Image
https://nkdagility.com/resources/OMGmyApgm0G
Subscribe

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
Subscribe

Related Blog

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.​

Slaughter and May Logo

Slaughter and May

SuperControl Logo

SuperControl

Lockheed Martin Logo

Lockheed Martin

Cognizant Microsoft Business Group (MBG) Logo

Cognizant Microsoft Business Group (MBG)

Milliman Logo

Milliman

ProgramUtvikling Logo

ProgramUtvikling

Epic Games Logo

Epic Games

Lean SA Logo

Lean SA

Genus Breeding Ltd Logo

Genus Breeding Ltd

Qualco Logo

Qualco

Emerson Process Management Logo

Emerson Process Management

Healthgrades Logo

Healthgrades

Microsoft Logo

Microsoft

Jack Links Logo

Jack Links

Sage Logo

Sage

Brandes Investment Partners L.P. Logo

Brandes Investment Partners L.P.

Deliotte Logo

Deliotte

NIT A/S

Washington Department of Transport Logo

Washington Department of Transport

New Hampshire Supreme Court Logo

New Hampshire Supreme Court

Ghana Police Service Logo

Ghana Police Service

Nottingham County Council Logo

Nottingham County Council

Department of Work and Pensions (UK) Logo

Department of Work and Pensions (UK)

Royal Air Force Logo

Royal Air Force

Lockheed Martin Logo

Lockheed Martin

Teleplan Logo

Teleplan

Kongsberg Maritime Logo

Kongsberg Maritime

Milliman Logo

Milliman

Capita Secure Information Solutions Ltd Logo

Capita Secure Information Solutions Ltd

Bistech Logo

Bistech