title: [System.Data.SqlClient.SqlCredential]: make sure the assembly containing this type is loaded
body: <p>I wrote a PowerShell script which can connect to SQL Server by using a secure connection string. I've tested this on my local PC and it works perfectly. But once I ran this script on server, it gave me the following error:</p>
  
  <blockquote>
    <p>Cannot find type [System.Data.SqlClient.SqlCredential]: make sure the assembly containing this type is loaded.</p>
  </blockquote>
  
  <p>Both machines (local and server) have .Net Framework 4.5 installed. Both connect to the same SQL Server. Both are PowerShell version 2.0. Local machine is Window 7 while Server is Window Server 2008 R2.</p>
  
  <p>In the scripts, I've included Assembly loaded.</p>
  
  <pre><code>[System.Reflection.Assembly]::Load("Microsoft.SqlServer.Smo,Version=11.0.0.0, Culture=Neutral,PublicKeyToken=89845dcd8080cc91") 
  [System.Reflection.Assembly]::Load("Microsoft.SqlServer.SqlEnum,Version=11.0.0.0, Culture=Neutral,PublicKeyToken=89845dcd8080cc91") 
  [System.Reflection.Assembly]::Load("Microsoft.SqlServer.ConnectionInfo,Version=11.0.0.0, Culture=Neutral,PublicKeyToken=89845dcd8080cc91")
  </code></pre>