SCI_tech
asked on
.NET Launching MS Word Programmatically while on Terminal Server Session
Greetings,
Our goal is to launch MS Word programmatically to a file we just created and saved to disk using a .docx template.
The catch is: we have to do this through a Terminal Server (virtual) session - logged into Windows 2008 R2 !
However, while we CAN successfully create directories, create MS Word files, and write these to disk through the TS session...we are NOT able to LAUNCH MS Word on the TS session programmatically. In other words, this "launch" portion is the only remaining part of the solution not yet working.
Furthermore, we ARE able to complete the launch using the following development environment / platform ...so we know the code "works"...:
- Windows 7 Workstation
- IE 9.0 Browser
- Microsoft Visual Studio 2010
- "Localhost" IIS App. Server
- Connecting to MS SQL Server
...and YES, we can launch MS Word 'manually' through the TS Session navigating to and then opening the file we JUST CREATED using .vb code...so we know that MS Word is working (appropriate CAL's, etc.) on the TS...
[ANY IDEAS WOULD BE GREATLY APPRECIATED ...THANKS MUCH!]
THIS CODE WORKS LOCALLY IN THE DEV ENVIRONMENT, BUT NOT THROUGH A TERMINAL SERVER SESSION:
========================== ========== ========== ========== =========
Private Sub LaunchWord (_fileToLaunch As String)
Try
Dim WordApp As Word.Application = New Word.Application()
Dim WordDoc As Word.Document = WordApp.Documents.Open(_fi leToLaunch )
WordDoc.Activate()
WordApp.Visible = True
Catch ex As Exception
'Response.Write("An Error Occurred: " & ex.ToString())
End Try
End Sub
========================== ========== ========== ========== =========
Our goal is to launch MS Word programmatically to a file we just created and saved to disk using a .docx template.
The catch is: we have to do this through a Terminal Server (virtual) session - logged into Windows 2008 R2 !
However, while we CAN successfully create directories, create MS Word files, and write these to disk through the TS session...we are NOT able to LAUNCH MS Word on the TS session programmatically. In other words, this "launch" portion is the only remaining part of the solution not yet working.
Furthermore, we ARE able to complete the launch using the following development environment / platform ...so we know the code "works"...:
- Windows 7 Workstation
- IE 9.0 Browser
- Microsoft Visual Studio 2010
- "Localhost" IIS App. Server
- Connecting to MS SQL Server
...and YES, we can launch MS Word 'manually' through the TS Session navigating to and then opening the file we JUST CREATED using .vb code...so we know that MS Word is working (appropriate CAL's, etc.) on the TS...
[ANY IDEAS WOULD BE GREATLY APPRECIATED ...THANKS MUCH!]
THIS CODE WORKS LOCALLY IN THE DEV ENVIRONMENT, BUT NOT THROUGH A TERMINAL SERVER SESSION:
==========================
Private Sub LaunchWord (_fileToLaunch As String)
Try
Dim WordApp As Word.Application = New Word.Application()
Dim WordDoc As Word.Document = WordApp.Documents.Open(_fi
WordDoc.Activate()
WordApp.Visible = True
Catch ex As Exception
'Response.Write("An Error Occurred: " & ex.ToString())
End Try
End Sub
==========================
Do you get any output? Errors, etc? Have you tried it in debug mode?
ASKER
Good question, here is error page on server with error tracking turned on...
Again, manually launching the outputted MS Word file DOES work...
Note: "Line 389" is the end sub of the LaunchWord sub - referenced above - from my OutputWord class... ( and of course CreateDate is the next function)
Thanks!
========================== ========== ========== ========== ========
========================== ========== ========== ========== ========
Server Error in '/' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Could not load file or assembly 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e 9429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadExceptio n: Could not load file or assembly 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e 9429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 387: End Try
Line 388:
Line 389: End Sub
Line 390:
Line 391: Private Function CreateDate() As String
Source File: D:\FAS\App_Code\OutputWord .vb Line: 389
Assembly Load Trace: The following information can be helpful to determine why the assembly 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e 9429c' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\F usion!Enab leLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\F usion!Enab leLog].
Stack Trace:
[FileLoadException: Could not load file or assembly 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e 9429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
OutputWord.LaunchWord(Stri ng _fileToLaunch) in D:\FAS\App_Code\OutputWord .vb:389
OutputWord.Petition_Approv ed_Letter( String _dfaNum, String _inputFileName, String _outputFileName) in D:\FAS\App_Code\OutputWord .vb:150
Main.btnUpdatePetition_Cli ck(Object sender, EventArgs e) in D:\FAS\Main.aspx.vb:1260
System.Web.UI.WebControls. Button.Rai sePostBack Event(Stri ng eventArgument) +154
System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt) +3707
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
Again, manually launching the outputted MS Word file DOES work...
Note: "Line 389" is the end sub of the LaunchWord sub - referenced above - from my OutputWord class... ( and of course CreateDate is the next function)
Thanks!
==========================
==========================
Server Error in '/' Application.
--------------------------
Could not load file or assembly 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadExceptio
Source Error:
Line 387: End Try
Line 388:
Line 389: End Sub
Line 390:
Line 391: Private Function CreateDate() As String
Source File: D:\FAS\App_Code\OutputWord
Assembly Load Trace: The following information can be helpful to determine why the assembly 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\F
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\F
Stack Trace:
[FileLoadException: Could not load file or assembly 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e
OutputWord.LaunchWord(Stri
OutputWord.Petition_Approv
Main.btnUpdatePetition_Cli
System.Web.UI.WebControls.
System.Web.UI.Page.Process
--------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
Main.btnUpdatePetition_Cli ck(Object sender, EventArgs e) in D:\FAS\Main.aspx.vb:1260
System.Web.UI.WebControls. Button.Rai sePostBack Event(Stri ng eventArgument) +154
System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt) +3707
Not only Terminal Services but using IIS! IIS runs in a sandbox and is designed specifically to disallow launching of executables outside of the sandbox. Which application pool is this using?
System.Web.UI.WebControls.
System.Web.UI.Page.Process
Not only Terminal Services but using IIS! IIS runs in a sandbox and is designed specifically to disallow launching of executables outside of the sandbox. Which application pool is this using?
ASKER
Can IIS be configured to allow specific exe's? Or, pass in some sort of pre-approved security token?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.