Optional Deployment

G

Gary Shell

I realize this may be more of a VB.NET question but I have a feeling no one
there will know the specifics of Visio so here goes. My VB.NET app which is
using the VISIO Interop OCX will be installed in various environments, some
of which may or may not have VISIO 2003 installed. The VISIO OCX is
instantiated on only one form. This one form resides in a separate project
inside my VB.NET Solution. The rest of the app resides in multiple forms in
three other projects under the same solution.

At install time, how can I determine if the user does not have VISIO 2003
and instruct them to try again after they have installed Visio 2003 or offer
to install the rest of the application without the VISIO files. I assume at
run time I can then check for the presence or absence of the VISIO related
form and disable that functionality.

Gary

I
 
A

Al Edlund

this snippet from one of the sample projects in the v2003 sdk (works fine in
mine)
Al
Try

If (vsoApplication Is Nothing) Then

vsoApplication = CType(application, _

Microsoft.Office.Interop.Visio.Application)

majorVersion = CType( _

Convert.ToDouble(vsoApplication.Version), Short)

' Make sure that we're running against the correct version of Visio.

If (0 = majorVersion Or _

majorVersion < MinVisioVersion) Then

If (vsoApplication.AlertResponse = 0) Then

applicationName = StringUtils.funcLoadString(StringUtils.SampleAppName)

System.Windows.Forms.MessageBox.Show( _

String.Format(StringUtils.funcLoadString(StringUtils.ErrorVisioVersion), _

applicationName), _

applicationName, _

System.Windows.Forms.MessageBoxButtons.OK, _

System.Windows.Forms.MessageBoxIcon.Error)

End If

Else
 
G

Gary Shell

But what if VISIO is not installed at all? In my instance, if the user does
not even have VISIO I want to be able to install and run the application and
just disable the VISIO required functionality.

Your code is helpful in determining if the user has the correct version.
But I am struggling with what to do if they have NO version.

Thanks,
Gary
 
A

Al Edlund

you might try to start it and test for the return , this is an example of
starting the app and some testing that might be done. You can also consider
trying to start it "invisible"
al

'Get the open instance of Visio
Set visApp = GetObject(, "Visio.Application")

If (visApp Is Nothing) Then
'there is no open instance of Visio, Create one
Set visApp = CreateObject("Visio.Application")
'Add a new blank drawing page
Set visDoc = visApp.Documents.Add("")
Else
'There was an open instance of Visio
If visApp.Documents.Count = 0 Then
'if there are no open documents in this instance of Visio,
'Add a new blank drawing
Set visDoc = visApp.Documents.Add("")
Else
'otherwise, get the currently active document
Set visDoc = visApp.ActiveDocument
End If
End If
 
G

Gary Shell

But I am not trying to start VISIO per se. I am using the VISIO interop OCX
and instantiating it on a form. If VISIO is not installed, the OCX will
not exist and the program will immediately die. Actually, I doubt if it
will even load.

I am going to have to set up a test environment for this and play around
with it.

But my biggest concern is not at run time. It's the install time issues (if
there are any). Again I haven't tried this yet, I am just investigating
what the pitfalls might be before I jump into it.

Gary
 
G

Gary Shell

Well, well, well. VB.NET was most helpful with this.

I was able to create an "optional deployment" scenario very easily. In my
Setup Project, I used the Launch Conditions Editor to create a File Search
to the "Search Target Machine" folder. This file search looks for
VISOCX.DLL in the ProgramFilesFolder to a depth of 10 sub folders. It then
sets a property named VISIOINSTALLED to true or false. Then in the File
System Editor I clicked on my interface dll named VisioInterface.DLL and set
its condition property to VISIOINSTALLED. Now if the installer finds the
VISOCX.DLL it installs my VisioInterface.DLL and if the ocx is not found, my
dll is not installed.

Now the GREAT part. Even if the VisioInterface.DLL is not installed on the
users machine my main form will still load just fine. The form load event
code looks for the VisioInterface.DLL and if it is not found the "Diagram"
menu option is hidden. (Note this only works because the main form does not
have a reference to the VisioInterface.DLL. That reference is in a
secondary form only instantiated if the user selected the "Diagrams" menu
option.)

I must say I am quite impressed with how much we can tailor or installs with
Vb.net. No real need for a third party tool anymore. (Well not YET anyway.
Grin)

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top