Error using external assembly from X++

I have a simple .NET assembly I’ve written in C# just for testing the use of external assemblies from within X++ code. The class just has a simple public method to take a string and write it to a database table. So the method signature is

public void DoSomething(string val){…}

After building the assembly and adding it to the GAC, I was able to add the reference in the AOT. I was also able to declare and initialize an instance of the class from within existing X++ code. However, for some strange reason, the DoSomething method is not recognized. I can’t compile the code, as it returns an error stating that the class “does not contain this function”.

Any ideas what I could be doing wrong?

Firstly you should be careful about the declaration and usage of the class. You should provide the full name of the type in your X++:

MyNamspace.MyClass instance = new MyNamespace.MyClass();

;

instance.DoSomething(‘aaaa’);

Another thing, if you added this assembly on the server and you are using the C# class in your AX client, you should create a X++ class as a wrapper and make it runon=“server”.