Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Custom Applications that Access TFS

Tags:

c#

tfs

We have built a custom application, for internal use, that accesses TFS. We use the Microsoft libraries for this (e.g Microsoft.TeamFoundation.dll).

When this application is deployed to PCs that already have Team Explorer or VS installed, everything is fine. When it’s deployed to PCs that don’t have this installed, it fails.

We include all the required DLLs, but the error we get is “Common Language Runtime detected and invalid program”. The error occurs on the moderately innocuous line:

TeamFoundationServer myServer = new TeamFoundationServer(“ourserver.ourdomain.com”);

Interestingly the popular TFSAdmin tool (when you drop in the required DLLs to the exe directory) gives the same error.

I also note that many other custom applications that access TFS (e.g. http://hinshelwood.com/tfsstickybuddy.aspx) also require Team Explorer or VS to be installed to work.

Clearly the DLLs are not enough and there is some magic that happens when these installs occur. Anyone know what it is? Anyone know how to make the magic happen?

like image 592
Handleman Avatar asked Dec 31 '22 09:12

Handleman


2 Answers

The "officially supported" way of writing an application that uses the TFS Object Model is to have Team Explorer installed on the machine. This is especially important for servicing purposes - i.e. making sure that when a service pack for VSTS is applied to the client machine then the TFS API's get upgraded as well. There are no re-distribution rights to the TFS API's therefore they should not be shipped with your application.

BTW - Also note that if you are writing an application that used the TFS OM, then be sure to compile it as "X86" only rather than "Any CPU". The TFS API assemblies are all marked X86, but if you app is marked "Any CPU" then on a x64 machine it will get loaded by the 64bit CLR but when it comes time to dynamically load the TFS Assemblies it will fail.

Good luck,

Martin.

like image 87
Martin Woodward Avatar answered Jan 01 '23 23:01

Martin Woodward


Try this list:

http://geekswithblogs.net/jjulian/archive/2007/06/14/113228.aspx

And also trying putting them in the GAC. It may be a security trust issue - assemblies in the GAC are granted a higher CAS level.

like image 40
Cory Foy Avatar answered Jan 02 '23 00:01

Cory Foy