Using licensing without built in dialog force closes my app - Advanced Installer Community
garjon
Posts: 3
Joined: Tue Jun 04, 2013 12:09 pm

Using licensing without built in dialog force closes my app

I'm wanting to use the Licensing component of Advanced Installer with a VB.Net application, but I want to have my own forms used instead of the built in ones.

I found this article, where the answer appear to be what I'm after. Basically, I call out to the "Trial.dll" library and make use of the return values of the functions to decide how my forms should behave.

http://www.advancedinstaller.com/forums ... =2&t=21295

To summarise:
- set the trial frequency to 0 days so our dialog is never shown (Licensing Display Options tab)
- use the ReadSettingsRetStr property mentioned in How do I integrate the licensing support in my application? article
-> if its value is 0 it means the product is already registered and there's no need to show your custom dialog
-> if its value is 2 you should enable the Try button ; to display the days left you can retrieve TrialLeft property (Trial and Licensing Properties) using the method described in How do I interrogate the licensing library to get license information? article
-> if its value is greater or equal than 4 you should disable the Try button, leaving Register and Buy
All is well up until the trial has expired. I've got the Trial Frequency value set to 0, so that the AI dialog never appears. If the trial has expired and I call out to the *ReadSettingsStr* function, my application just exits; there's no exception, it just exits. I'm guessing it's calling something like Process.Kill() under the hood. This appears to be the same behavior as if I had clicked the "Cancel" button when I show the built in dialog.

If I set the "Trial Frequency" to 100 in the AI project, the built in dialog appears and lets me provide a registration code. After that, my application loads without problem.

Is there something special I need to do to stop the application from getting closed?
garjon
Posts: 3
Joined: Tue Jun 04, 2013 12:09 pm

Re: Using licensing without built in dialog force closes my

Anyone? Should I be contacting support directly rather than going through this forum for this one?
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Using licensing without built in dialog force closes my

Hello and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

I'm not sure why this happens. Please give us some time to investigate this and we'll get back to you as soon as we have a conclusive answer.

Thank you for your patience and understanding.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Using licensing without built in dialog force closes my

Hello,

Can you please tell us if the related "trial.dll" used by your application is also installed by your application installation package? In order to use the above scenario the "trial.dll" file should be installed using the installation project of your application. The 'trial.dll" used by your application should be the one installed with your installation package.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
garjon
Posts: 3
Joined: Tue Jun 04, 2013 12:09 pm

Re: Using licensing without built in dialog force closes my

The "Trial.dll" that I'm using is the same one that is installed by the installation package. As I mentioned, if I change the Advanced Installer project to display the trial dialog 100 percent of the time, it will show up with the "Try" option simply disabled (once the trial has expired). This is how I'm sure I'm using the correct "Trial.dll".
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Using licensing without built in dialog force closes my

Hello,
All is well up until the trial has expired. I've got the Trial Frequency value set to 0, so that the AI dialog never appears. If the trial has expired and I call out to the *ReadSettingsStr* function, my application just exits; there's no exception, it just exits. I'm guessing it's calling something like Process.Kill() under the hood. This appears to be the same behavior as if I had clicked the "Cancel" button when I show the built in dialog.
Please keep in mind that you should call the "ReadSettingsRetStr" function and not the "ReadSettingsStr" function. Can you confirm that the called function when your application exits is "ReadSettingsRetStr"?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bhavinjo
Posts: 7
Joined: Wed Sep 18, 2013 3:22 am

Re: Using licensing without built in dialog force closes my

Hi,
I am having the exact same issue. I am unabe to use DisplayRegistration method in my C# console application. The application just quits. I have set the Display Frequency Percent to 0. Interestingly setting it to number > 0 always keeps popping the registration dialog even when the user is in trial

Here is the code I am using.

private const string kLibraryKey = "actualLibrarayKey";

[DllImport("Trial.dll", EntryPoint = "ReadSettingsRetStr", CharSet = CharSet.Ansi)]
static extern uint InitTrialReturn(String aKeyCode, IntPtr aHWnd);

[DllImport("Trial.dll", EntryPoint = "DisplayRegistrationStr", CharSet = CharSet.Ansi)]
static extern uint DisplayRegistration(String aKeyCode, IntPtr aHWnd);

private static void checkRegistrationStatus()
{
try
{
Process process = Process.GetCurrentProcess();
uint ret = InitTrialReturn(kLibraryKey, process.MainWindowHandle);

if (ret >= 4)
{
DisplayRegistration(kLibraryKey, process.MainWindowHandle);
Process.GetCurrentProcess().Kill();
}
}
catch (DllNotFoundException exTrialDllNotFound)
{
// Trial dll is missing close the application immediately.
MessageBox.Show(exTrialDllNotFound.ToString());
Process.GetCurrentProcess().Kill();
}
catch (Exception exCheckRegistrationStatus)
{
MessageBox.Show(exCheckRegistrationStatus.ToString());
Process.GetCurrentProcess().Kill();
}
}

Then in main

checkRegistrationStatus();

Any help is much appreciated!
bhavinjo
Posts: 7
Joined: Wed Sep 18, 2013 3:22 am

Re: Using licensing without built in dialog force closes my

Any inputs on this issue? Anyone?
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Using licensing without built in dialog force closes my

Hi,

Please note that this topic discusses about how to NOT show the predefined dialog "DisplayRegistrationDlg". If you want to use our default dialog please use our sample code, it was tested so it should work.

If you do not want to use the predefined dialog, do not call the method DisplayRegistrationStr, instead use the method ReadSettingsRetStr to get the info you need, then display your own custom dialog,
using the results returned by our DLL.

Best regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bhavinjo
Posts: 7
Joined: Wed Sep 18, 2013 3:22 am

Re: Using licensing without built in dialog force closes my

Thanks for your reply.

I want to use the in built dailogs but the problem is, if I set the display frequency to anything > 0 for e.g. 1, even when the product is in trial, the trial dialog box still shows up after running the app just once saying 29 runs left for example. Upon hitting cancel on it, the application just quits. Since its still in trial, it should not kill the app upon hitting cancel.

The problem is after running the app only once, return code is 5 although its still in trial.

I have followed the code from tutorial example as below

Code: Select all

private const string kLibraryKey = "actualKey";

		[DllImport("Trial.dll", EntryPoint = "ReadSettingsRetStr", CharSet = CharSet.Ansi)]
		static extern uint InitTrialReturn(String aKeyCode, IntPtr aHWnd);

		private static void checkRegistrationStatus()
		{			
			try
			{
				Process process = Process.GetCurrentProcess();
				uint retCode = InitTrialReturn(kLibraryKey, process.MainWindowHandle);

				if (retCode >= 4)
				{
					Process.GetCurrentProcess().Kill();
				}
			}
			catch (DllNotFoundException exTrialDllNotFound)
			{				
				MessageBox.Show(exTrialDllNotFound.ToString());
				Process.GetCurrentProcess().Kill();
			}
			catch (Exception exCheckRegistrationStatus)
			{
				MessageBox.Show(exCheckRegistrationStatus.ToString());
				Process.GetCurrentProcess().Kill();
			}
		}
And then in main

Code: Select all

checkRegistrationStatus();
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Using licensing without built in dialog force closes my

Hello,

You can see my response on the following link from the forums:
Using licensing with in built dialog force closing the app.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”