Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Condition Property of CustomAction
 

Condition Property of CustomAction

Hi,
In a Setup and deployment project i added a dialog called Textboxes (A). In that dialog I have a textbox EDITA1. I would like to know How can I set the Condition Property so that if the user does not enter anything in that textbox the installation should not continue.

To try this from code I created a custom class inherited from Installer but its not working. The code I tried is given below.

Code Snippet

Imports System.ComponentModel
Imports System.Configuration.Install

<RunInstaller(True)> Public Class InstallerConfiguration
Inherits Installer

Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)

If Context.Parameters("MyTextBox") = String.Empty Then
Throw New InstallException("Please enter a value!")
End If

End Sub

End Class

Thx in advance.

ajeeshco  Wednesday, June 06, 2007 4:32 AM
I don' think MSI sets the property to string.empty. It might be a single space or something that needs trimming before it corresponds to string.empty.
PhilWilson  Sunday, June 10, 2007 7:00 PM

In the properties for that editboxes dialog there'll be a property in uppercase associated with the editbox (it might even be EDITA1). You need to pass that in via CustomActionData as something like:

/ed1=[EDITA1]

and then get the value in your code in ......Parameters.Item("ed1") IIRC the StringDictionary properties.

PhilWilson  Wednesday, June 06, 2007 9:03 PM
PhilWilson wrote:

then get the value in your code in ......Parameters.Item("ed1") IIRC the StringDictionary properties.

Hi PhilWilson,

Thanks for the reply. As you said,in my codeI tried to check whether the value is empty or notas follows.

if(Context.Parameters["ed1"] == string.Empty)

{

throw new InstallException("Value can't be null!");

}

But eventhough I don't enteranything in that textbox itis not throwing any exception.

ajeeshco  Thursday, June 07, 2007 3:35 AM
I don' think MSI sets the property to string.empty. It might be a single space or something that needs trimming before it corresponds to string.empty.
PhilWilson  Sunday, June 10, 2007 7:00 PM

Hi PhilWilson,

Thanks. Now the problem is solved, I'm comparing like this

Code Snippet

If Context.Parameters("MyVariable") = Nothing Then

Throw New InstallException("MyVariable is nothing")

End If

ajeeshco  Monday, June 18, 2007 4:45 AM

You can use google to search for other answers

Custom Search

More Threads

• installer, desktop icon a possibility?
• What I would like to see in the generatebootstrapper task
• deploy smart client that uses caching app block
• drag+drop onto desktop shortcuts generated by Windows Installer
• Integrated Database
• Setup and deployment project problem
• How to merge two different solution into single install file.
• Check if user has just updated the application?
• ClickOnce and Web Services
• ClickOnce Question