Skip to main content

Automating with .NET

This guide shows you how to automate AdSec using the .NET API. This allows you to build applications or integrations for tasks such as creating sections, running analyses, and extracting results.

By following this guide, you will:

  • Set up a .NET development environment
  • Install the AdSec API
  • Activate your license
  • Run a working .NET application

Before proceeding, ensure you meet the general requirements for automating with AdSec.

Step 1: Set up your .NET project

Create a new .NET project using your preferred IDE (e.g. Visual Studio). For simplicity, you can use a console application.

For example, run the following commands in your terminal:

dotnet new console -n AdSecExample
cd AdSecExample

The API also supports .NET Framework 4.7.2 or later, but .NET Core 3.1 or later is strongly recommended.

Step 2: Install the AdSec API

Add the AdSec API package to your project using NuGet. If you are unfamiliar with NuGet, you can follow this guide from Microsoft: NuGet documentation.

Step 3: Activate your license

The AdSec API requires a license. To activate it, you will need:

  • A license number
  • A password

If you do not have these, contact Oasys support.

Run the activation code

Add the following code to your project, run it, and enter your license number and password when prompted:

using System;
using Oasys.AdSec;

namespace AdSecExample
{
class Program
{
static void Main(string[] args)
{
Console.Write("Please enter your license number: ");
var licenseNumber = Console.ReadLine();

Console.Write("Please enter your password: ");
var password = Console.ReadLine();

var res = ILicense.ActivateLicense(licenseNumber, password);
Console.WriteLine("Activated: " + res.ActionStatus);

Console.WriteLine("Product: " + res.ProductInformation.ProductName);
Console.WriteLine("Version: " + res.ProductInformation.Version);
Console.WriteLine("Company: " + res.LicenseInformation.CompanyName);
Console.WriteLine("LicenseId: " + res.LicenseInformation.LicenseId);
Console.WriteLine("Seats remaining: " + res.LicenseInformation.NumberOfSeats);
Console.WriteLine("Days left: " + res.LicenseInformation.NumberOfDays);

foreach (var warning in res.Warnings)
{
Console.WriteLine(warning.Description);
}
}
}
}

Step 4: Verify activation

Your license is successfully activated when the application runs without errors and prints license information.

Run this short script to confirm everything is set up:

using Oasys.AdSec;
Console.WriteLine("AdSec API version: " + IVersion.Api());

If a version number is printed, your setup is complete.

If activation fails, check the following:

If the issue persists, contact Oasys support.

Step 5: Run your first application

You are now ready to run AdSec automations using .NET. To get started, run one of the sample projects:

AdSec .NET sample files

Step 6: You are ready to build

You have now:

  • Set up a .NET environment
  • Installed the AdSec API
  • Activated your license
  • Run a sample application

Start building AdSec automations with .NET