title: c# interop.word - printout - randomly changed printer settings
body: <p>I'm having a really weird problem with Interop.</p>
  <p>I developed a small program that opens a <strong>Microsoft.Office.Interop.Word.Application</strong> and use it to prints documents:</p>
  <pre><code>object[] oWordDialogParams = { printerName, true };
  string[] argNames = { &quot;Printer&quot;, &quot;DoNotSetAsSysDefault&quot; };
  object wordBasic = wordApplication.WordBasic;
  try
  {
    wordBasic.GetType().InvokeMember(&quot;FilePrintSetup&quot;
    , BindingFlags.InvokeMethod
    , null
    , wordBasic
    , oWordDialogParams
    , null
    , null
    , argNames);
  }
  catch (Exception e)
  {
    Logger.Instance.Log(&quot;failed to set printer&quot;);
  }
  doc.Activate(); 
  wordApplication.PrintOut(Background: ref backgroundPrint, FileName: ref sourceFile);
  </code></pre>
  <p>Everything works fine pretty always (I would say 95% of the times), I'm able to see the correct print queue and, most important, the printer settings are <strong>the default printer settings</strong> (i.e.: nothing happens in the printer preferences):</p>
  <p><a href="https://i.stack.imgur.com/ETwss.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ETwss.png" alt="ok" /></a></p>
  
  <p>But, in a few cases, the document is passed to the printer without the extension (docx in this case) <strong>and the printer setting are changed (for example the paper size is set to letter)</strong>:</p>
  <p><a href="https://i.stack.imgur.com/XC481.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XC481.png" alt="notok" /></a></p>
  
  <p>Please note that:</p>
  <ul>
  <li><p>in my code the <em>FileName: ref sourceFile</em> is always correctly set with the extension, but (randomly!) it appears in the print queue without the extension. <strong>When this happens it means also that the printer settings are changed to something not default</strong>.</p>
  </li>
  <li><p>the exact same document reprinted works fine (!)</p>
  </li>
  </ul>
  <p>I'm working with:</p>
  <ul>
  <li>framework 4.0</li>
  <li>interop 12.0</li>
  <li>windows server 2008 R2</li>
  <li>the printer uses the HP Universal Print Driver</li>
  </ul>
  <p>Thank you all for your precious help!</p>