Asked By ian_morgan
04-Nov-09 08:58 PM

Hi Forum,
This is my first post, so please be gentle with me :)
I have created a Mobile application, using Visual Studio 2008 Professional. I
used VB.NET as the language.
The App works OK, so I am now looking to deploy it neatly. I have created a
custom installer, and this works fine. The stuff that is working fine is
described here, to give you a picture of where I have got to:
User will run a Setup.exe file on a desktop, which calls the MSI file, which
deploys my cab file and resource files onto the Mobile device. The MSI file
then uses a custom action to call a custom installer to invoke the ceappmgr
to install the cab file on the device. This is all perfect.
However, I need to have two parameters specified at the point of installing
the MSI onto the Desktop PC, and the Mobile application needs to reference
those, so I need to ideally get these parameters to be present on the Mobile
device as a parameter file. Any file would be fine, but XML makes most sense.
I have been able to collect these parameters by adding a new form in the user
interface options of the MSI file. I think I am passing these correctly to my
custom installer, but am struggling to work out how to debug this.
However, how do I take these parameters that have arrived in my custom
installer class, and write them to a config file, which will find it is way
onto the Mobile device?
I can find lots of tutorials on parts of this, but nothing that puts it all
together. I'd be very grateful if someone could look at the 'ProblemPart'
marked in the custom installer script below, and let me know where I am going
wrong !
[Code]
Imports System.Windows.Forms
Imports System.Diagnostics
Imports System.Reflection
Imports System.IO
Imports Microsoft.Win32
Imports System.Xml
Inherits System.Configuration.Install.Installer
Private Const INI_FILE As String = "\setup.ini"
Private Sub Installer_AfterInstall(ByVal sender As Object, ByVal e As
System.Configuration.Install.InstallEventArgs) Handles MyBase.AfterInstall
' ========== PROBLEM PART ===============
Dim path As String = Context.Parameters("path")
Dim Webservices As String = Context.Parameters("Webservices")
Dim SoiWebservices As String = Context.Parameters("SoiWebservices")
'Now create an object writer to send the file to
Dim objWriter As XmlTextWriter
objWriter = New XmlTextWriter(path, System.Text.Encoding.Default)
'start writing the XML document
objWriter.WriteStartDocument()
'starting with the root element
objWriter.WriteStartElement("Parameters")
objWriter.WriteElementString("WebServices", Webservices)
objWriter.WriteElementString("SoiWebServices", SoiWebservices)
objWriter.WriteEndElement()
'flush and write XML data to the file
objWriter.Flush()
objWriter.Close()
objWriter = Nothing
' ========== PROBLEM PART ===============
'---to be executed when the application is installed---
Dim ceAppPath As String = GetWindowsCeApplicationManager()
If ceAppPath = String.Empty Then
Return
End If
Dim iniPath As String = GetIniPath()
Process.Start(ceAppPath, iniPath)
End Sub
Private Sub Installer_AfterUninstall(ByVal sender As Object, ByVal e As
System.Configuration.Install.InstallEventArgs) Handles MyBase.AfterUninstall
'---to be executed when the application is uninstalled---
Dim ceAppPath As String = GetWindowsCeApplicationManager()
If ceAppPath = String.Empty Then
Return
End If
Dim iniPath As String = GetIniPath()
Process.Start(ceAppPath, String.Empty)
End Sub
Public Shared Function GetWindowsCeApplicationManager() As String
'---check if the Windows CE Application Manager is installed---
Dim ceAppPath As String = KeyExists()
If ceAppPath = String.Empty Then
MessageBox.Show("Windows CE App Manager not installed", "Setup",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Return String.Empty