R
Russ Green
I am currently developing an application in VB.NET that uses the Microstation's object model via COM Interop.
I have a problem regarding multiple instances of the Microstation application (ustation.exe) and calling the COM object in multiple forms in my application.
The Microstation Application object is demnsioned in Common.mod
Public oMSTN As MicroStationDGN.Application
My application is entered in StartUp.mod and there is a routine that determines if Microstation is already running or not. Different forms load depending on if the user already has an instance if Microstation running or not.
##############################################
# CODE EXECUTED IN STARTUP.MOD #
# TO START MICROSTATION IF IT ISN'T #
# ALREADY RUNNING #
# #
# oMSTN DIMENSIONED IN COMMON.MOD #
# Public oMSTN As Application #
##############################################
Private Sub CheckForProject()
If IsProcessExecuting("ustation") = False Then
projectForm = New frmProj
projectForm.ShowDialog()
Else
'process is executing so get the project
'configuration file currently selected
'and set project ID from database
oMSTN = New MicrostationDGN.Application
sConfigName = oMSTN.ActiveWorkspace.ConfigurationVariableValue("_USTN_PROJECTNAME")
lProj_ID = GetProjIDFromDb(sConfigName)
End If
End Sub
If Microstation is running then a new instance of oMSTN must be started so that my application can read a microstation configuration variable. That works fine, howver, when other forms load I don't know how to reference the same instance of oMSTN. Starting new instances of oMSTN in each form simply starts and extra instance of ustation.exe running in task manager.
How do I start a call this code once "oMSTN = New MicrostationDGN.Application" in my startup module and then use oMSTN in every form that loads after that?
Thanks in advance
Russ
I have a problem regarding multiple instances of the Microstation application (ustation.exe) and calling the COM object in multiple forms in my application.
The Microstation Application object is demnsioned in Common.mod
Public oMSTN As MicroStationDGN.Application
My application is entered in StartUp.mod and there is a routine that determines if Microstation is already running or not. Different forms load depending on if the user already has an instance if Microstation running or not.
##############################################
# CODE EXECUTED IN STARTUP.MOD #
# TO START MICROSTATION IF IT ISN'T #
# ALREADY RUNNING #
# #
# oMSTN DIMENSIONED IN COMMON.MOD #
# Public oMSTN As Application #
##############################################
Private Sub CheckForProject()
If IsProcessExecuting("ustation") = False Then
projectForm = New frmProj
projectForm.ShowDialog()
Else
'process is executing so get the project
'configuration file currently selected
'and set project ID from database
oMSTN = New MicrostationDGN.Application
sConfigName = oMSTN.ActiveWorkspace.ConfigurationVariableValue("_USTN_PROJECTNAME")
lProj_ID = GetProjIDFromDb(sConfigName)
End If
End Sub
If Microstation is running then a new instance of oMSTN must be started so that my application can read a microstation configuration variable. That works fine, howver, when other forms load I don't know how to reference the same instance of oMSTN. Starting new instances of oMSTN in each form simply starts and extra instance of ustation.exe running in task manager.
How do I start a call this code once "oMSTN = New MicrostationDGN.Application" in my startup module and then use oMSTN in every form that loads after that?
Thanks in advance
Russ