Purpose
This library is used to make easier the creation of add-in inside the application than just using the raw API.
Create C# project with Visual Studio
To start the creation of an add-in, you need to:
- Open Visual Studio
- File -> New -> Project
- Select Visual C# -> Class Library (.NET Framework)
Click Next.
Click Create.
In the solution tree -> Go to project properties.
Verify that solution platform is x64
In the Build Events tab, In the Post-build events command line Add this comand line: C:\WINDOWS\Microsoft.NET\Framework64\$(frameworkversion)\regasm.exe "$(TargetPath)" /codebase
Rename Class1.cs file with an appropriate name for the add-in.
Modify code to make the add-in
Open Assemblyinfo.cs:
Verify that you have ComVisible(true) and not ComVisible(false).
Include references
Go to "Tools->Manage Nuget Packages for Solution..."
Select Package source: nuget.org.
In Browse, Select ElectricalAddinSDK:
And click on "Install":
Click on "OK":
Check under References, if you see:
- ElectricalAddinSDK
- NLog
- SimpleInjector
Right click on Reference and select Add reference...
Add EwAPI Browse to the location of EwAPIX.dll
Modify code to implement the interface in the Add-in
In your Class interface (HelloWorld.cs):
- Add: using System.Runtime.InteropServices;
- Add: using ElecworksAddinSdk.General;
- Add: using EwAPI;
Like in screen shot below:
Create a main class which inherit AddinBasicSkeleton
and implement mandatory methods
Finally add those methods to your main class to register this add-in:
[ComRegisterFunction]
public static void RegisterFunction(Type t)
{
RegisterAddin(
t,
description: "My beautiful add-in",
title: "My add-in"
);
}
[ComUnregisterFunction]
public static void UnregisterFunction(Type t)
{
UnregisterAddin(t);
}
public override EwErrorCode OnConnectToEwAPI(
object ewInteropFactory)
{
EwErrorCode baseConnectionResult = base.OnConnectToEwAPI(ewInteropFactory);
return baseConnectionResult;
}
- Note
- License Code(*): Contact your reseller to get your license code