Using the licensing support with c# - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

acmd
Posts: 1
Joined: Thu Mar 04, 2010 4:05 pm

Using the licensing support with c#

Hello,
i can't use the licensing support in c#! i make a test app and have a errormessage on start! System.AccessViolationException

here is the test app (kLibraryKey is not real ;)):
using .NET 2.0

Code: Select all

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace ACTestApp
{
	class Program
	{
		[DllImport("Trial.dll", EntryPoint = "ReadSettingsStr", CharSet = CharSet.Ansi)]
		static extern uint InitTrial(String aKeyCode, IntPtr aHWnd);
		
		[DllImport("Trial.dll", EntryPoint = "DisplayRegistrationStr", CharSet = CharSet.Ansi)]
		static extern uint DisplayRegistration(String aKeyCode, IntPtr aHWnd);

		public static void Main()
		{
			OnInit();
			Console.WriteLine("Welcome to ACTestApp!");
			Console.ReadKey();
		}		
		
		private const string kLibraryKey = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		private static void OnInit() 
		{
		 try
		 {
		   Process process = Process.GetCurrentProcess();
		   InitTrial(kLibraryKey, process.MainWindowHandle);
		 }
		 catch (DllNotFoundException ex)
		 {
		   Console.WriteLine(ex.ToString());
		   Process.GetCurrentProcess().Kill();
		 }   
		 catch(Exception ex1) 
		 {
		   Console.WriteLine(ex1.ToString());
		 }
		}
	}
}
thanks for help!
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Using the licensing support with c#

Hello,

In your C# solution, right click your project and go to Properties. Go to the "Build" page and make sure you have x86 or x64 selected as the platform target. Make sure it's not "Any CPU". Also, make sure DEP is not activated for your executable.

In Advanced Installer, go to the Licensing page. On the Options tab select "32-bit ANSI Library ( supports Win9x or higher)" from the Target Platform combo box.

Alternately you can leave DEP enabled in your C# project, then in Advanced Installer select "32-bit Unicode Library (DEP aware)" from the combo.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”