Error Message : Word has encountered a problem. Target Site : Microsoft.Office.Interop.Word.Document Add(System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef)
public MSWordMapping(string templateName, byte[] templateStream) : base(templateName, templateStream) { try { this.wordApp = new Microsoft.Office.Interop.Word.Application(); this.wordDoc = this.wordApp.Documents.Add(templateName, false, Microsoft.Office.Interop.Word.WdNewDocumentType.wdNewBlankDocument, true); this.wordDoc.SaveAs(this.DocumentName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocumentDefault); this.wordDoc.Close(true, Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat, Type.Missing); this.releaseObject(this.wordDoc); this.wordDoc = null; this.wordDoc = this.wordApp.Documents.Open(FileName: this.DocumentName); this.wordDoc.Activate(); } catch { this.DeleteFile(); throw; } }
Put a folder called Desktop on C:\Windows\SysWOW64\config\systemprofile (Yes I know. WTF?) Open Regedit, Go to HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppId and edit the two enteries that have a Guid ending with 46. Delete every key they have and add a new key called RunAs with the value of Interactive User After that, start praying. It doesn't work if you access through a terminal server. Which is kind of a problem for me hehe.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)