CAB and VSTO-Excel

Topics: CAB & Smart Client Software Factory
Jan 18, 2007 at 9:35 PM
What is the best way to create a CAB application and access it from within Excel application developped using VSTO?
We tried the following:
a) Public Class DmxEdfGuiAppBase
Inherits FormShellApplication(Of WorkItem, MainForm1)
...
end class

b) we "patched" the following code in
CabApplication:

add an optional parameter StartOn
to the Run method
Public Sub Run(Optional ByVal StartOn As Boolean = True)
RegisterUnhandledExceptionHandler()
Dim builder As Builder = CreateBuilder()
AddBuilderStrategies(builder)
CreateRootWorkItem(builder)

Dim visualizer As IVisualizer = CreateVisualizer()
If Not visualizer Is Nothing Then
visualizer.Initialize(innerRootWorkItem, builder)
End If

AddRequiredServices()
AddConfiguredServices()
AddServices()
AuthenticateUser()
ProcessShellAssembly()
innerRootWorkItem.BuildUp()
LoadModules()
innerRootWorkItem.FinishInitialization()

innerRootWorkItem.Run()
' PATCHES
If StartOn Then
Start()

innerRootWorkItem.Dispose()
If Not visualizer Is Nothing Then
visualizer.Dispose()
End If
Else
Show()
End If
End Sub

and add a new method
Public MustOverride Sub Show()

then in
Public MustInherit Class FormShellApplication(Of TWorkItem As {WorkItem, New}, TShell As Form)
Inherits WindowsFormsApplication(Of TWorkItem, TShell)

''' <summary>
''' Calls <see cref="Application.Run(Form)"/> to start the application.
''' </summary>
Protected Overrides Sub Start()
Application.Run(Shell)
End Sub
' PATCHES
Public Overrides Sub Show()
Me.Shell.Show()
End Sub
End Class

Finally in Exccel we added a menu item
and run the following:

Dim gprogram As New DmxEdfGuiAppBase()
gprogram.Run(False)

This seems to work fine but is it???

Is there a more direct way to do the same?

Any feedabck will be greatly appreciated...

Thank you
Jan 18, 2007 at 9:40 PM
Check if this helps:

http://staff.southworks.net/blogs/matiaswoloski/archive/2006/02/26/230.aspx
http://staff.southworks.net/blogs/matiaswoloski/archive/2006/02/26/HostingCAB.aspx

You don't have to patch anything. Just implement a CabApplication derived class. Check those articles and let me know if they helped

Matias
http://staff.southworks.net/blogs/matiaswoloski
Jan 18, 2007 at 10:28 PM
Matias, Thank you. It will certainly help us.

Marc