|
-
February 3rd, 2004, 11:35 AM
#1
Nested Executables run from ASP.NET. The inner one hangs!!!
Nested Executables run from ASP.NET. The inner one hangs!!!
This is what is supposed to happen:. I am running a web-based ASP.NET app. It shell executes another (VB 6.0 based) executable "C:\MyFolder\Visio_Opener_Executable.exe". This executable in turn opens a Visio 2000 map. After the map opens, it is processed with info from the database and a gif file ("NGB_Basemap_Timestamp_AllGrey1_raster.gif") to be used in the code is made out of it. After the gif file is made a map is closed.
But that is not the way thinhgs happen. There is a "visio.exe" that I do not see (as it is supposed to be) but shows up in the "Windows Task Manager" process list and and does not go away - it hangs. If I ran the app 10 times, I will end up with 10 incidents of "visio.exe"
The gif is not even formed.
When I run the executable "C:\MyFolder\Visio_Opener_Executable.exe" by double clicking on it, a visio windows opens up, a gif file is mede and "visio.exe" does not show up in the task manager.
How do I get around my problems.
Would it help if "C:\MyFolder\Visio_Opener_Executable.exe" code is from VB.NET instead of VB 6.0?
<code>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Diagnostics" %>
<%@ Import Namespace="System.IO" %>
<html>
<body>
<form action="ChartTest.aspx" action="POST">
Value 1: <input type="text" name="v1" value="<%= Request("v1") %>"><br>
Value 2: <input type="text" name="v2" value="<%= Request("v2") %>"><br>
Value 3: <input type="text" name="v3" value="<%= Request("v3") %>"><br><br>
<input type="submit" value="Redraw Bar Chart"><br><br>
</form>
<script language="VB" runat="server">
Dim sngValue1 As Single, sngValue2 As Single, sngValue3 As Single
Sub Page_Load()
'Set a time-out value.
Dim timeOut As Integer = 10000
'Get the path to the system folder.
Dim sysFolder As String = _
Environment.GetFolderPath(Environment.SpecialFolder.System)
'Create a new ProcessStartInfo structure.
Dim pInfo As New ProcessStartInfo()
'Set the file name member of pinfo to the executable.
'pInfo.FileName = "notepad.exe"
pInfo.FileName = "C:\MyFolder\Visio_Opener_Executable.exe"
'Start the process.
Dim p As Process = Process.Start(pInfo)
'Wait for the process window to complete loading.
p.WaitForInputIdle()
'Wait for the process to exit.
p.WaitForExit(timeOut)
'HasExited is true if the application closed before the time-out.
If p.HasExited = False Then
'Process is still running.
'Test to see if process is hung up.
If p.Responding Then
'Process was responding; close the main window.
p.CloseMainWindow()
' mmk 2.2.2004 added
p.Kill()
Else
'Process was not responding; force the process to close.
p.Kill()
End If
End If
End Sub
</script>
<img src="C:\Inetpub\Wwwroot\visiomap\NGB_Basemap_Timestamp_AllGrey1_raster.gif">
</body>
</html>
'
"C:\MyFolder\Visio_Opener_Executable.exe" is made out of VB 6.0 (not VB.NET) and the
function is as below:
......................................................
......................................................
Private Function ProcessMapShapes()
'Instance of master on page
Dim appVisio As Visio.Application
On Error GoTo TrapIt
Set appVisio = CreateObject("visio.application")
Set docObj = appVisio.Documents.Open(destFile)
Print #logFileInt, separatorStr
Print #logFileInt, "DONE lauching a VISIO App"
' Create a document based on the Basic Diagram template which
' automatically opens the Basic Shapes stencil.
' Set docObj = docsObj.Add("Geographic Maps.vst")
Set pagsObj = appVisio.ActiveDocument.Pages
.......... code deleted.........
appVisio.Quit
Exit_This:
Exit Function
TrapIt:
Resume Exit_This
End Function
.................
..................
..................
</code>
-
February 3rd, 2004, 03:05 PM
#2
First let me say that I think it's your code in the VB6 app that is leaving Visio running. I don't have Visio on this computer so I can't test it, but that would be my best guess.
A couple things you can try to fix this:
1) It looks like if at anytime an error is thrown, the appVisio.Quit will NOT get called. Make sure you are not getting an error somewhere and it's getting handled incorrectly.
Code:
TrapIt:
msgbox("ERROR!" & err.description)
End Function
2) Very important, Destroy those objects!
Code:
appVisio.Quit
'
'Destroy!!
'
Set appVisio = Nothing 'DESTROYED!
Set docObj = Nothing 'DESTROYED!
'
'That's the poor mans asteriods
'
3) Instead of creating the object "CreateObject("visio.application")", try adding the Visio COM object as a reference. I'm not sure why this would make any difference, but it does with some objects.
4) When you appVisio.Quit, are you absolutely sure that it has finished processing what you were doing, otherwise, it may just be ignoring your request to close? Is there a way to test if it's still doing something (I have no idea if something like this exists):
Code:
appVisio.Quit
If appVisio.IsBusy then wait
Good Luck,
Craig - CRG IT Solutions - Microsoft Gold Partner
-My posts after 08/2015 = .NET 4.x and Visual Studio 2015
-My posts after 11/2011 = .NET 4.x and Visual Studio 2012
-My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
-My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
-My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
-My posts before 04/2007 = .NET 1.1/2.0
*I do not follow all threads, so if you have a secondary question, message me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|