Jiange Sun's WebLog

TFS SDK will cause InvalidProgramException while running as 64 bit

Issue:

=====

You create a C# project that uses TFS SDK. But it crashes when you try to run it on a X64 bit OS machine:

 

Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.

   at Microsoft.TeamFoundation.Client.TeamFoundationServerFactory.GetServer(String name)

   at TFSTestProject.Program.Main(String[] args)

 

This is the code that causes crash:

TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://<server>:<port>",);

Root Cause:

==========

The TFS OM is not going to work correctly in a native 64-bit mode. For C# project, it’s default platform target is “Any CPU” (aka,  X64 on a 64-bits OS).

 

Resolution:

=========

Go to Project Property of your C# project, click on Build tab, set “Platform Target” to x86, rebuilt. Now the program will run as a 32 bit executable and TFS OM work fine.

Published Friday, March 28, 2008 10:18 AM by jianges
Filed under:
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker