This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- External C# dll to validate serial number
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 26, 2011
10:34 PM
External C# dll to validate serial number
Please help me with this, I am fumbling in the dark trying to solve my problem using this community and knowledge base, but it certainly is not logical to figure this stuff out.
I am trying to include .dll file written in C# in a basic MSI project to validate serial number.
My method is called "validateSN" and has a string parameter and returns an int (0 or 1). I want to pass the ISX_SERIALNUM value to my method/function.
Here are my steps and questions:
1. When adding a custom action do I use standard dll or managed code?
a. Here is what I get when custom action is managed code:
Class1.validateSN(...)
b. Here is what I get when custom action is standard dll:
NUMBER=[LICENCE_OK]stskv2::validateSN(in STRING=[ISX_SERIALNUM]
2. Do I need to do anythinge else than in all the other options?
3. These are the events I am doing in the CustomerInformation Dialog:
- DoAction LicenceCheck 1
- NewDialog SetupType LICENSE_OK
- EndDialog Exit not LICENSE_OK
Does this look right? I am just returning 0 or 1 so honestly I dont understand where LICENSE_OK comes in, but I read it somewhere in this forum. Am I going in the right direction? Is this supposed to work? What might be wrong becuase it is just exiting out before really doing anything. I put a messagebox.show in my dll to see if it even enters the method, but it seems it is not.
I am trying to include .dll file written in C# in a basic MSI project to validate serial number.
My method is called "validateSN" and has a string parameter and returns an int (0 or 1). I want to pass the ISX_SERIALNUM value to my method/function.
Here are my steps and questions:
1. When adding a custom action do I use standard dll or managed code?
a. Here is what I get when custom action is managed code:
Class1.validateSN(...)
b. Here is what I get when custom action is standard dll:
NUMBER=[LICENCE_OK]stskv2::validateSN(in STRING=[ISX_SERIALNUM]
2. Do I need to do anythinge else than
3. These are the events I am doing in the CustomerInformation Dialog:
- DoAction LicenceCheck 1
- NewDialog SetupType LICENSE_OK
- EndDialog Exit not LICENSE_OK
Does this look right? I am just returning 0 or 1 so honestly I dont understand where LICENSE_OK comes in, but I read it somewhere in this forum. Am I going in the right direction? Is this supposed to work? What might be wrong becuase it is just exiting out before really doing anything. I put a messagebox.show in my dll to see if it even enters the method, but it seems it is not.
(11) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 27, 2011
05:15 PM
Custom actions have to return 0 (zero) for success (please see Custom Action Return Values). Hence, the return value of your custom action wouldn't be the most appropriate for LICENSE_OK property. There should be a separate out variable for LICENSE_OK property.
You can refer to "C:\Program Files\InstallShield\2011\Samples\WindowsInstaller\Managed Custom Actions" for an example.
You can refer to "C:\Program Files\InstallShield\2011\Samples\WindowsInstaller\Managed Custom Actions" for an example.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 27, 2011
10:50 PM
OK....I got my code to run!!! YAYYYY!!! Thank you so much for pointing me in right direction for me to get some clues.
I seem to only have one issue left now, it is not exiting when serial number is unsuccessfule. I'm not sure what you mean by "separate out". Can you elaborate?
This is my C# method:
public int validateSN(string SN)
{
string serialmac = "";
string readmac = "";
serialmac = createMac(SN);
readmac = GetMacAddress();
if (serialmac == readmac)
{
return 0;
}
else
{
MessageBox.Show("Serialnumber is incorrect. Please try again or call support and provide this information for a new serial number: " + readmac);
return 1;
}
}
I seem to only have one issue left now, it is not exiting when serial number is unsuccessfule. I'm not sure what you mean by "separate out". Can you elaborate?
This is my C# method:
public int validateSN(string SN)
{
string serialmac = "";
string readmac = "";
serialmac = createMac(SN);
readmac = GetMacAddress();
if (serialmac == readmac)
{
return 0;
}
else
{
MessageBox.Show("Serialnumber is incorrect. Please try again or call support and provide this information for a new serial number: " + readmac);
return 1;
}
}
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 27, 2011
11:07 PM
Actually, let me refrase that, I want the NewDialog to trigger only if it is successful. If unsuccessful I want it to do nothing. I guess I could have exit after a certain amount of tries, but that's secondary.
Right now NewDialog trigger all the time weather it is successful or not.
I've tried to set condition LICENSE_OK, LICENSE_OK="0", LICENSE_OK="1" and not LICENSE_OK, but none of those conditions makes a difference.
Right now NewDialog trigger all the time weather it is successful or not.
I've tried to set condition LICENSE_OK, LICENSE_OK="0", LICENSE_OK="1" and not LICENSE_OK, but none of those conditions makes a difference.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 28, 2011
01:29 AM
I don't have VS and IS IDE at home, so hopefully I get the syntax correct.
public int validateSN(string SN, out string licenseOK)In your 1b, it may look something like below. LICENSE_OK can then be used to control ControlEvents.[code]NUMBER=[SOME_RC]stskv2::validateSN(in STRING=[ISX_SERIALNUM], out STRING=[LICENSE_OK])[/code]As for why NewDialog ControlEvent keeps firing, check the value of LICENSE_OK property in Property table and also (more reliably) in verbose installation log, and refer to Condition column in ControlEvent Table. According to your 1b, you appear to be setting LICENCE_OK property.
{
string serialmac = "";
string readmac = "";
serialmac = createMac(SN);
readmac = GetMacAddress();
if (serialmac == readmac)
{
licenseOK = "0";
}
else
{
// Can do this with SpawnDialog ControlEvent
// personally, i will recommend against displaying literal string message inside a custom action.
// It makes localization, L10N, impossible.
MessageBox.Show("Serialnumber is incorrect. Please try again or call support and provide this information for a new serial number: " + readmac);
licenseOK = "1";
}
// return other value when an exception occurs or something.
// unless you are ignoring return code in your custom action, a non-zero return code indicates an installation error, and will stop installation.
return ERROR_SUCCESS;
}
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 28, 2011
09:01 AM
Where can I find installation log?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 28, 2011
09:33 AM
%temp% .
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 28, 2011
01:20 PM
Microsoft Windows Installer does not generate log by default. It can be turned on from inside the MSI file (MsiLogging Property, requiring Windows Installer 4.0 and later) , with Command-Line Options to msiexec.exe or by setting system Logging policy.
cwilliamsson wrote:
Where can I find installation log?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 06, 2011
09:05 AM
I have a custom DLL that validates the serial number entered by the user. I have set conditions on the Customer Information dialog to spawn a dialog on validation fail and to proceed to next screen on validation success. My problem is that I have to click the Next button twice in order for conditions to work properly. For example, on a fail serial clicking Next does nothing but clicking Next a second time launches the spawn dialog. Same thing with a valid serial, on first click nothing happens but clicking Next again proceeds to next screen. What gives?
Thanks in advance.
Thanks in advance.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 07, 2011
02:10 PM
My first guess is the sequence of ControlEvents may be off.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 12, 2011
11:24 AM
Yes, that was the issue. Thank you.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 13, 2011
03:11 PM
Now that you have the basic pattern working, I'd just looking at WiX DTF CA's.