title: command line c# code works, but winforms code does not
body: <p>I am working on a <a href="https://grmorc.echosign.com/public/docs/EchoSignDocumentService19#sendDocument" rel="nofollow">Adobe Echosign</a> demo C# winforms application. My code is a direct copy of their command line code (with modifications), however, my code returns an error after it transmits the data.    </p>
  
  <p>This is the command line code from <a href="https://grmorc.echosign.com/public/docs/EchoSignDocumentService19#sendDocument" rel="nofollow">EchoSign</a> that works  </p>
  
  <pre><code>public static void sendDocument(string apiKey, string fileName, string formFieldLayerTemplateKey, string recipient)
  {
      FileStream file = getTestPdfFile(fileName);
      secure.echosign.com.FileInfo[] fileInfos = new secure.echosign.com.FileInfo[1];
      fileInfos[0] = new secure.echosign.com.FileInfo(fileName, null, file);
      SenderInfo senderInfo = null;
      string[] recipients = new string[1];
      recipients[0] = recipient;
      DocumentCreationInfo documentInfo = new DocumentCreationInfo(
          recipients,
          testPrefix + Path.GetFileName(file.Name),
          testMessage,
          fileInfos,
          SignatureType.ESIGN,
          SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED
      );
      if (formFieldLayerTemplateKey != null)
      {
          secure.echosign.com.FileInfo[] formFieldLayerTemplates = new secure.echosign.com.FileInfo[1];
          formFieldLayerTemplates[0] = new secure.echosign.com.FileInfo(formFieldLayerTemplateKey);
          documentInfo.formFieldLayerTemplates = formFieldLayerTemplates;
      }
      DocumentKey[] documentKeys;
      documentKeys = ES.sendDocument(apiKey, senderInfo, documentInfo);
      Console.WriteLine("Document key is: " + documentKeys[0].documentKey);
  }
  </code></pre>
  
  <p>This is my code block that returns an error from their system:  </p>
  
  <pre><code>public static void sendDocument(string apiKey, string fileName, string formFieldLayerTemplateKey, string recipient)
  {
      try
      {
          SenderInfo senderInfo = new SenderInfo();
          senderInfo = null;
  
          FileStream FileToSign = getTestPdfFile(fileName);
          byte[] bytes = System.IO.File.ReadAllBytes("C:\\PROJECTS\\TestFile.pdf");
  
  
          secure.echosign.com.FileInfo[] fileInfos = new secure.echosign.com.FileInfo[1];
          fileInfos[0] = new EchoSignTest.secure.echosign.com.FileInfo();
          fileInfos[0].fileName = fileName;
          fileInfos[0].mimeType = null;
          fileInfos[0].file = bytes;
  
          RecipientInfo[] docRecipient = new RecipientInfo[1];
          docRecipient[0] = new RecipientInfo();
          docRecipient[0].email = recipient;
  
          DocumentCreationInfo documentInfo = new DocumentCreationInfo();
          documentInfo.recipients = docRecipient;
          documentInfo.name = testPrefix + Path.GetFileName(FileToSign.Name);
          documentInfo.message = testMessage;
          documentInfo.fileInfos = fileInfos;
          documentInfo.signatureType = SignatureType.ESIGN;
          documentInfo.signatureFlow = SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED;
  
          if (formFieldLayerTemplateKey != null)
          {
              secure.echosign.com.FileInfo[] formFieldLayerTemplates = new secure.echosign.com.FileInfo[1];
  
              formFieldLayerTemplates[0] = new secure.echosign.com.FileInfo();
              formFieldLayerTemplates[0].formKey = formFieldLayerTemplateKey;
              documentInfo.formFieldLayerTemplates = formFieldLayerTemplates;
          }
  
          EchoSignDocumentService19PortTypeClient ES = new EchoSignDocumentService19PortTypeClient();
          DocumentKey[] documentKeys = new DocumentKey[1];
  
          documentKeys = ES.sendDocument(apiKey, senderInfo, documentInfo);
          Console.WriteLine("Document key is: " + documentKeys[0].documentKey);
      }
      catch (NullReferenceException ex)
      {
          string errMessage = ex.Message;
      }
  
      catch (Exception ex)
      {
          string errMessage = ex.Message;
      }
  }  
  </code></pre>
  
  <p>What is different between the two code blocks?  The error may reside in the <code>FileInfo[]</code> or <code>DocumentCreationInfo()</code> blocks. I am perhaps not creating the objects as the system requires.  </p>
  
  <p>Any suggestions are appreciated.</p>