System.InvalidProgramException<span>  <p>Hi,</p> <p align=left>I have a console application which uses Team Foundation APIs. It works perfectly well on my system, but when deployed onto a server, throws weird errors. </p> <p align=left>This is the exception:</p> <p align=left>System.InvalidProgramException: Common Language Runtime detected an invalid program.<br>   at Microsoft.TeamFoundation.Client.TeamFoundationServerFactory.GetServer(String name).</p> <p align=left> </p> <p align=left>This is the statement that throws the exception:</p><font color="#2b91af" size=2> <p>TeamFoundationServer</font><font size=2> objTFS = </font><font color="#2b91af" size=2>TeamFoundationServerFactory</font><font size=2>.GetServer(</font><font color="#a31515" size=2>&quot;http://&quot;</font><font size=2>+strApplicationServer+</font><font color="#a31515" size=2>&quot;:8080&quot;</font><font size=2>);</p></font> <p align=left> </p> <p align=left>I read about this exception and turned off Optimisation hoping that would resolve the problem. It did not help. I even used the PE Verifier to verify the MSIL, and it showed no errors.</p> <p align=left> </p> <p align=left>Now, I have no clue how to fix the problem. Please help.</p> <p align=left> </p> <p align=left><font face=Arial size=2>Thanks.</font></p></span> <p align=left><font face=Arial size=2></font> </p>© 2009 Microsoft Corporation. Tous droits réservés.Fri, 10 Oct 2008 00:14:40 Zcc18ba2f-5dc1-4677-9fb4-c869cb869780http://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#cc18ba2f-5dc1-4677-9fb4-c869cb869780http://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#cc18ba2f-5dc1-4677-9fb4-c869cb869780Sanjuktahttp://social.msdn.microsoft.com/Profile/fr-FR/?user=SanjuktaSystem.InvalidProgramException<span>  <p>Hi,</p> <p align=left>I have a console application which uses Team Foundation APIs. It works perfectly well on my system, but when deployed onto a server, throws weird errors. </p> <p align=left>This is the exception:</p> <p align=left>System.InvalidProgramException: Common Language Runtime detected an invalid program.<br>   at Microsoft.TeamFoundation.Client.TeamFoundationServerFactory.GetServer(String name).</p> <p align=left> </p> <p align=left>This is the statement that throws the exception:</p><font color="#2b91af" size=2> <p>TeamFoundationServer</font><font size=2> objTFS = </font><font color="#2b91af" size=2>TeamFoundationServerFactory</font><font size=2>.GetServer(</font><font color="#a31515" size=2>&quot;http://&quot;</font><font size=2>+strApplicationServer+</font><font color="#a31515" size=2>&quot;:8080&quot;</font><font size=2>);</p></font> <p align=left> </p> <p align=left>I read about this exception and turned off Optimisation hoping that would resolve the problem. It did not help. I even used the PE Verifier to verify the MSIL, and it showed no errors.</p> <p align=left> </p> <p align=left>Now, I have no clue how to fix the problem. Please help.</p> <p align=left> </p> <p align=left><font face=Arial size=2>Thanks.</font></p></span> <p align=left><font face=Arial size=2></font> </p>Thu, 21 Feb 2008 04:44:43 Z2008-02-21T04:44:43Zhttp://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#fdf31583-2165-41e2-98b5-709b4543946fhttp://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#fdf31583-2165-41e2-98b5-709b4543946fScott Piegdonhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=Scott%20PiegdonSystem.InvalidProgramException Have you found any resolution to this problem?  I am experiencing the same issue.  My code is a bit different, because I switched from the factory to the constructor during the debugging of this, but still the first time I try to reference the object generated I get it also:<br><br><span class=tx><strong>System.InvalidProgramException: Common Language Runtime detected an invalid program. at Microsoft.TeamFoundation.Client.TeamFoundationServer.op_Equality(TeamFoundationServer tfs1, TeamFoundationServer tfs2) <br><br></strong><font size=2> <p></font><font color="#008000" size=2><font color="#008000" size=2>// Connect to the team foundation server<br></font></font><font color="#2b91af" size=2><font color="#2b91af" size=2>TeamFoundationServer</font></font><font size=2> tfs = </font><font color="#0000ff" size=2><font color="#0000ff" size=2>new</font></font> <font color="#2b91af" size=2><font color="#2b91af" size=2>TeamFoundationServer</font></font><font size=2>(<br></font><font color="#2b91af" size=2><font color="#2b91af" size=2>     ConfigurationManager</font></font><font size=2>.AppSettings[</font><font color="#a31515" size=2><font color="#a31515" size=2>&quot;tfsServer&quot;</font></font><font size=2>],<br></font><font color="#0000ff" size=2><font color="#0000ff" size=2><font color="#2b91af" size=2><font color="#2b91af" size=2>     </font>     </font>new</font></font><font size=2> System.Net.</font><font color="#2b91af" size=2><font color="#2b91af" size=2>NetworkCredential</font></font><font size=2>(<br></font><font color="#2b91af" size=2><font color="#2b91af" size=2><font color="#2b91af" size=2>     <font color="#2b91af" size=2>     </font><font color="#2b91af" size=2>     </font></font>ConfigurationManager</font></font><font size=2>.AppSettings[</font><font color="#a31515" size=2><font color="#a31515" size=2>&quot;tfsUser&quot;</font></font><font size=2>],<br></font><font color="#2b91af" size=2><font color="#2b91af" size=2><font color="#2b91af" size=2>     <font color="#2b91af" size=2>     <font color="#2b91af" size=2>     </font></font></font>ConfigurationManager</font></font><font size=2>.AppSettings[</font><font color="#a31515" size=2><font color="#a31515" size=2>&quot;tfsPassword&quot;</font></font><font size=2>],<br></font><font color="#2b91af" size=2><font color="#2b91af" size=2><font color="#2b91af" size=2>     <font color="#2b91af" size=2>     <font color="#2b91af" size=2>     </font></font></font>ConfigurationManager</font></font><font size=2>.AppSettings[</font><font color="#a31515" size=2><font color="#a31515" size=2>&quot;tfsDomain&quot;</font></font><font size=2>]));<br></font><font color="#0000ff" size=2><font color="#0000ff" size=2><br>if</font></font><font size=2> (tfs == </font><font color="#0000ff" size=2><font color="#0000ff" size=2>null</font></font><font size=2>)<br></font><font color="#0000ff" size=2><font color="#0000ff" size=2><font color="#2b91af" size=2>     </font>throw</font></font> <font color="#0000ff" size=2><font color="#0000ff" size=2>new</font></font> <font color="#2b91af" size=2><font color="#2b91af" size=2>Exception</font></font><font size=2>(</font><font color="#a31515" size=2><font color="#a31515" size=2>&quot;Unable to connect to TFS Service&quot;</font></font><font size=2>);<br><br>I am very stuck at this point, I have made some very cool sharepoint add-ins that communicate with TFS, however even in a stand alone web application, I cannot seem to access TFS from the server via code.<br><br>Please let me know if anyone has any ideas.<br><br>Thanks!<br>Scott Piegdon</p></font></span>Wed, 13 Aug 2008 14:39:28 Z2008-08-13T14:39:28Zhttp://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#29e5524c-4ec7-42b6-ad4c-cac85514b81fhttp://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#29e5524c-4ec7-42b6-ad4c-cac85514b81fnobugzhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=nobugzSystem.InvalidProgramExceptionIf you are running this code on a 64-bit OS, force the CLR to run in 32-bit mode with the Build, Platform = x86 override. <hr size="1" align="left" width="25%">Hans Passant.Fri, 15 Aug 2008 10:19:29 Z2008-08-15T10:19:29Zhttp://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#3b619307-4db5-44a5-92b8-260611f9a6d4http://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#3b619307-4db5-44a5-92b8-260611f9a6d4Dickie Howarthhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=Dickie%20HowarthSystem.InvalidProgramExceptionHi,<br><br>I'm having the same probelm when trying to connect to the TF Server.<br><br>Did you find a resolution to your problem? I'm not running a 64bit OS, and I have had this code working on the server when running through VS Team edition on the server. <br><br>Now I have migrated the code to a client, could there be a licence issue, as I do not have the Client licence on the machine contacting the server?<br><br>I would have thought there would be a more meaningful error message if it was this though,<br><br>I would be grateful for any comments,<br><br>Thanks.<br>Tue, 07 Oct 2008 10:33:44 Z2008-10-07T10:33:44Zhttp://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#fcfa415b-e2c7-4f22-b374-02ee04d9c6fahttp://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#fcfa415b-e2c7-4f22-b374-02ee04d9c6fasm0kkiehttp://social.msdn.microsoft.com/Profile/fr-FR/?user=sm0kkieSystem.InvalidProgramException I am having the same issue running against TFS 2008 while programming in C# in either VS 2005 or 2008.  My error, however, is being thrown while trying to create a new instance of <font color="#2b91af" size=2><font color="#2b91af" size=2>TeamFoundationServer. I am running on x86 and have forced the platform as such. Any ideas?</font></font>Wed, 08 Oct 2008 03:34:57 Z2008-10-08T03:36:47Zhttp://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#1dafea03-338d-4477-a3ae-2b30766772a2http://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#1dafea03-338d-4477-a3ae-2b30766772a2Michael Bird from Sharp Dudeshttp://social.msdn.microsoft.com/Profile/fr-FR/?user=Michael%20Bird%20from%20Sharp%20DudesSystem.InvalidProgramException Are the TFS client DLLs present on the machine you're deploying the code to? Does the licensing even allow you to put them there if they are not?<hr size="1" align="left" width="25%">Please mark the post if it answers your question.Thu, 09 Oct 2008 13:47:06 Z2008-10-09T13:47:06Zhttp://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#11c103dd-3e2d-4ffe-a189-7efd99d1a2b4http://social.msdn.microsoft.com/Forums/fr-FR/clr/thread/cc18ba2f-5dc1-4677-9fb4-c869cb869780#11c103dd-3e2d-4ffe-a189-7efd99d1a2b4Tim Chenhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=Tim%20ChenSystem.InvalidProgramException<p>You have to verify the IIS Server have Team Explorer 2008 installed in order for the code to run.<br><br>Tim</p>Fri, 10 Oct 2008 00:14:40 Z2008-10-10T00:14:40Z