Microsoft Interop Word Winforms issue on CITRIX
-
Hi, I have a developed a winforms app with c# as the language. Integrated a word object model (Microsoft.Interop.Word 12.0 library) to fill in a word document from a word template using bookmarks. The application opens the word document on button click. This workd fine on my local machine, but when installed on a CITRIX server it is giving an error on button click (Null reference exception). The word doc opens fine when the button is clicked once, but when i close the word doc and re-click on the same button its throwing an exception.
private void btn_Click(object sender, EventArgs e) { oWordApp = new Word.Application(); oWordDoc = new Word.Document(); object missing = System.Reflection.Missing.Value; object oTemplate = "C:\\Program Files\\MyTemplate.dot"; oWordDoc = oWordApp.Documents.Add(ref oTemplate, ref missing, ref missing, ref missing); object oBookMark = "Date"; oWordDoc.Bookmarks.get_Item(ref oBookMark).Range.Text = DateTime.Now.ToShortDateString(); oWordApp.Application.Visible = true; oWordApp.WindowState = Word.WdWindowState.wdWindowStateNormal; } Does any one know how to resolve this issue?
-
Hi, I have a developed a winforms app with c# as the language. Integrated a word object model (Microsoft.Interop.Word 12.0 library) to fill in a word document from a word template using bookmarks. The application opens the word document on button click. This workd fine on my local machine, but when installed on a CITRIX server it is giving an error on button click (Null reference exception). The word doc opens fine when the button is clicked once, but when i close the word doc and re-click on the same button its throwing an exception.
private void btn_Click(object sender, EventArgs e) { oWordApp = new Word.Application(); oWordDoc = new Word.Document(); object missing = System.Reflection.Missing.Value; object oTemplate = "C:\\Program Files\\MyTemplate.dot"; oWordDoc = oWordApp.Documents.Add(ref oTemplate, ref missing, ref missing, ref missing); object oBookMark = "Date"; oWordDoc.Bookmarks.get_Item(ref oBookMark).Range.Text = DateTime.Now.ToShortDateString(); oWordApp.Application.Visible = true; oWordApp.WindowState = Word.WdWindowState.wdWindowStateNormal; } Does any one know how to resolve this issue?
The first thing you need to do is add some code to find out which object is giving the null reference, and then figure out why. Are you certain that everything is correctly installed on the other system to support your app?
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
The first thing you need to do is add some code to find out which object is giving the null reference, and then figure out why. Are you certain that everything is correctly installed on the other system to support your app?
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
yeah, Word is installed on the host machine and its loading all the assemblies (so its working on button click) and its throwing a Null reference exception when the same button is clicked the second time ie after the word doc is closed and the button is clicked again.
-
yeah, Word is installed on the host machine and its loading all the assemblies (so its working on button click) and its throwing a Null reference exception when the same button is clicked the second time ie after the word doc is closed and the button is clicked again.
Well, as I suggested before, you need to add some debug code to find out which object is throwing the exception.
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman