Я пишу веб-сервис, используя c # для замены словесных закладок.
Следующий код работает в разработке, но не работает в Windows Server.
Невозможно открыть слово в следующей строке
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref CopyOfTemplate, ref confirmConversions, ref readOnly, ref addToRecentFiles, ref passwordDoc, ref passwordTemplate, ref revert, ref writepwdoc, ref writepwTemplate, ref format, ref encoding, ref visible, ref openRepair, ref docDirection, ref notEncoding, ref xmlTransform);
Версия Word в обеих средах - 2013.
На сервере я вижу запущенный текстовый процесс в задаче, но он зависает. CPU 0%.
Microsoft.Office.Interop.Word._Application wordApp = new Microsoft.Office.Interop.Word.Application();
wordApp.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsMessageBox;
// wordApp.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
wordApp.Visible = true;
object confirmConversions = Type.Missing; object readOnly = Type.Missing; object addToRecentFiles = Type.Missing; object passwordDoc = Type.Missing; object passwordTemplate = Type.Missing; object revert = Type.Missing; object writepwdoc = Type.Missing; object writepwTemplate = Type.Missing; object format = Type.Missing; object encoding = Type.Missing; object visible = Type.Missing;
object openRepair = Type.Missing;
object docDirection = Type.Missing; object notEncoding = Type.Missing; object xmlTransform = Type.Missing;
if (!File.Exists(CopyOfTemplate.ToString()))
{
throw new Exception("template does not exists ");
}
File.AppendAllText(Path.Combine(Settings.RealFilePath, "log.txt"), "\r\n before open;CopyOfTemplate="+ CopyOfTemplate);
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref CopyOfTemplate, ref confirmConversions, ref readOnly, ref addToRecentFiles, ref passwordDoc, ref passwordTemplate, ref revert, ref writepwdoc, ref writepwTemplate, ref format, ref encoding, ref visible, ref openRepair, ref docDirection, ref notEncoding, ref xmlTransform);