title: use of ScardConnect function (winscard.dll) in Wcf
body: <p>I am trying Connecting to smartcard with using connect function of winscard.dll in my WCF project. Wcf service, is publishing with remote machine which machine is installed on windows server 8.1</p>
  
  <p>ScardConnect function is returning value of 6.</p>
  
  <pre><code>public int Connect()
                  {
                      int returnCode = -2;
                      string[] tempStr = new string[3];
  
                      returnCode = ModWinsCard.SCardEstablishContext(ModWinsCard.SCARD_SCOPE_USER,
   0, 0, ref hContext);
  
                      if (returnCode == ModWinsCard.SCARD_S_SUCCESS)
                      {
                          returnCode = ModWinsCard.SCardConnect(hContext, "ACS ACR1281 1S Dual Reader PICC 0", ModWinsCard.SCARD_SHARE_SHARED, ModWinsCard.SCARD_PROTOCOL_T0 | ModWinsCard.SCARD_PROTOCOL_T1, ref hCard, ref pdwActiveProtocol);
  
                          if (returnCode == ModWinsCard.SCARD_S_SUCCESS)
                              return 1;
                          else
                              return returnCode;
                      }
                      else
                          return returnCode;
                  }
  
  
    Interface (IService1)
  </code></pre>
  
  <p>[OperationContract]
          [FaultContract(typeof(Service1))]
          int Connect(int hContext, string szReaderName, ref int phCard, ref int ActiveProtocol);</p>
  
  <p>ScardConnect function</p>
  
  <pre><code>[DllImport("winscard.dll")]
      public static extern int SCardConnect(int hContext, string szReaderName, int dwShareMode, int dwPrefProtocol, ref int phCard, ref int ActiveProtocol);
  </code></pre>
  
  <p>What does it mean return code '6'.  </p>
  
  <p>Note: Wcf project build action : x86
  Client project build action: x86</p>