Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Microsoft Interop Word Winforms issue on CITRIX

Microsoft Interop Word Winforms issue on CITRIX

Scheduled Pinned Locked Moved C#
csharphelpwinformscomsysadmin
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spankyleo123
    wrote on last edited by
    #1

    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?

    L 1 Reply Last reply
    0
    • S spankyleo123

      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?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • L Lost User

        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

        S Offline
        S Offline
        spankyleo123
        wrote on last edited by
        #3

        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.

        L 1 Reply Last reply
        0
        • S spankyleo123

          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.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups