Building a COM Interop Assembly to use with Microsoft Dexterity

I am currently building some customizations for a customer of mine in the aerospace industry. My customer required a library of trigonometric functions that could be used to extend their Dexterity integrating applications.

To solve this problem, we turned to .NET to create COM interop assembly. The idea was to take advantage of the standard Math class methods available with the System namespace - System.Math . The following is an excerpt of the code we created:

TrigonometricFunctions.cs

//Created by Mariano Gomez, MVP
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace TrigonometricFunctions
{
public class TrigonometricFunctions
{
[GuidAttribute("8268A95E-6FCB-4FB2-88A1-1E38F49F4FB8"), ClassInterface(ClassInterfaceType.AutoDual)]
public class TrigFn
{
// dx in degrees
public double fSin(double dx)
{
double angle = Math.PI * dx / 180.0;
// returns sin(dx)
return Math.Sin(angle);
}

// dx in degrees
public double fCos(double dx)
{
double angle = Math.PI * dx / 180.0;
// returns cos(dx)
return Math.Cos(angle);
}

// dx in degrees
public double fTan(double dx)
{
double angle = Math.PI * dx / 180.0;
// returns tan(dx)
return Math.Tan(angle);
}

}
}
}


Once the functions in the TrigFn class were in place, we set up the assembly information in Visual Studio's marking the option to Make assembly COM visible.


So we did not have to register the assembly manually, we took advantage of Visual Studio's ability to register the assembly for COM interop under the Build settings. For purposes of demostration, I created a simple Dexterity form, as shown below:



The following is the code added to the '(L) Sine' button:

Sine button CHG script

{ script: l_Sine_CHG }

local TrigonometricFunctions oTrig;
local currency angle, sine;

oTrig = new TrigonometricFunctions.TrigFn();

'(L) Prompt' = "The Sine value is ";
'(L) Conversion' = oTrig.fSin('(L) Angle');

In the code above, TrigonometricFunctions is a data type created after adding the TrigonometricFunctions COM interop assembly as a library to our Dexterity application. The data type references the TrigonometricFunctions.TrigFn class.

References:

  • Using a .NET Assembly from a Dexterity-Based Application - Click here
  • Microsoft Dynamics GP 10.0 White Paper: Using a .NET Assembly from a Dexterity-based Application - Click here


  • Downloads:

    TrigonometricFunctions .NET project - Click here
    Dexterity Sample App - Click here

    Until next post!

    MG.-
    Mariano Gomez, MVP
    Maximum Global Business, LLC
    http://www.maximumglobalbusiness.com/

    Comments

    Shabeeh said…
    Hi
    Excellent article. but i have strange problem. Same library that you mentioned in your article works good on GP10 i.e. dexterity 10 (i am able to reference .net library successfully) but the same library dont appear in GP2010 i.e. in dexterity 11 reference window?

    Can you please help?

    Popular posts from this blog

    DBMS: 12 Microsoft Dynamics GP: 0 error when updating to Microsoft Dynamics GP 2013 R2

    Do I have to use those "Z-" currency IDs in GP?

    Microsoft Dynamics GP Scrolling Windows and Line Sequence Numbers