Eror while Adding dll fiels to Ax 2009

Hi All,

I copied dot net dll file to client bin folder and i selected the dll file from add reference window by using reference node in AX 2009 AOT. But it giving error as “Invalid Object Name”. dll file developed using .Net frame work4.0. And same file i can able to deploy from AX 2012 and i can able to access methods defined in dll files. Can you please let me know why this error giving in AX 2009.

Thanks

Anilkumar

http://www.axaptapedia.com/.NET_Integration

Use .NET 3.5 when building assemblies for AX 2009.

Thanks Martin.

Can you please tell me how to pass our AX 2009 Class as a parameter in method.

It’s not supported by AX 2009. You can only pass primitive X++ types (see How to: Marshal Between X++ and CLR Primitive Types) and .NET types. Therefore do the following:

  1. Create a .NET for holding values (of primitive types) you need.
  2. Expose properties or methods for setting the values.
  3. Create an instance of the .NET class in X++.
  4. Set the values from X++.
  5. Use the instance of the .NET class as a parameter in your method call.

Hi Martin,

The dot net dll which is developed using .Net Frame Work 3.5 also can’be able to deploy. It giving same error “Invalid Object Name”. Why this error coming i could not able to under stand. Please let me know is there any alternate. .Net guys saying dll working fine our side, do we need to set any configuration in our Ax 2009 environment.

When do you get the error? When adding the reference? Or is it thrown by the X++ compiler? Can you share the file?

Hi Martin,

Thanks for update, when i click on Add reference in Reference node of AOT then in the grid i could not able to see any assemblies which are place in GAC and if i select the dll in client bin folder then also it is not showing in second grid. Can you please update me why assemblies not showing in Grid? Is there any licence issues for this?

If you don’t see assemblies from GAC, something is wrong with your system, but I obviously can’t know what.

Verify that you don’t have any customizations in the area of application and check whether you get data in SysGAC::readAssemblyReferences(). If you get data there, the problem is merely in displaying, if you don’t, it’s probably somewhere in Windows.

Thanks Martin, the problem is we don’t have license code for classes. So it’s giving invalid object name.

Hi Martin,

dot net dll having method like AddProduct(Product product, string.Enum enum, double val);

Here Product is the Class, here i need to call this AddProduct() method in our AX 2009 and need to pass classs instance in place of Product.

Can you please explain me how to pass class instance with small example.

Thanks

You have to create an instance of the .NET class Product and pass it to the method as usual. Don’t forget to use fully-qualified names. For example, if the class is in YourApp namespace and it has a parameterless constructor, you would create an instance by this code:

YourApp.Product product = new YourApp.Product();

You’ll find more in .NET CLR Interop Overview on MSDN.

I passed Class instance as you said, i created one class product in yourApp class library.

then i add reference in our AX 2009 AOT and in job i wrote code like this,

YourApp.Product product = new YourApp.Product();

ClassLibrary.Class cls = new ClassLibrary.Class(); //

cls.AddProduct(product, “d”,“ef”); // this is a method defined in another dll, here product is the class

but it showing error as ClassLibrary**.**Class doesn’t contain this function

And does it? Is the method public? Does it accept one YourApp.Product and two strings?

If you don’t see anything wrong, please show your implementation of ClassLibrary.Class.

This one i created in dot net class library

namespace PropertiesLibrary

{

class Class1

{

string name;

string id;

public Class1(string Sname, string Sid)

{

name = Sname;

id = Sid;

}

public string Name

{

set { name = value;}

get { return name;}

}

public string Id

{

set { id = value;}

get { return id;}

}

IN AX 2009

In job:

PropertiesLibrary.Class1 prop;

ClassLib.Class cls;

;

prop = new PropertiesLibrary.Class1(“Maritn”, “101”);

cls = new ClassLib.Class(); // this one is developed by other dot net guys

cls.AddProduct(prop, “df”,“dfde”); // here it expecting Class, string, string types in AddProduct() method

Here when i pass prop then it showing error as The Clas ClassLib.Class doesn’t contain this function.

Can you show us the implementation of the class you have problem with, i.e. ClassLib.Class()? Also, is AddProduct() offered by IntelliSense?

This one i created in dot net class library

namespace PropertiesLibrary

{

class Class1

{

string name;

string id;

public Class1(string Sname, string Sid)

{

name = Sname;

id = Sid;

}

public string Name

{

set { name = value;}

get { return name;}

}

public string Id

{

set { id = value;}

get { return id;}

}

IN AX 2009

In job:

PropertiesLibrary.Class1 prop;

ClassLib.Class cls;

;

prop = new PropertiesLibrary.Class1(“Maritn”, “101”);

cls = new ClassLib.Class(); // this one is developed by other dot net guys

cls.AddProduct(prop, “df”,“dfde”); // here it expecting Class, string, string types in AddProduct() method

Here when i pass prop then it showing error as The Clas ClassLib.Class doesn’t contain this function.

I don’t have code for ClassLib.Class because those are developed by dot net people.

ClassLib.Class having one more function which expecting string values only, when I send string values into that function it’s working fine. But problem is coming with AddProduct() function only because it’s original function in dot net is like this AddProduct(Class class, String name, sting age)

So while consume this function from AX 2009 we need to pass class instance. When I try to pass class instance of .Net class which is developed by me giving error.

It it expects ClassLib.Class, you can give it PropertiesLibrary.Class1.

when i give AddProduct(PropertiesLibrary.Class1, “df”,dr") , error giving like this Table is out of range or doesn’t exist.

You have to create an instance, of course. And it’s still a wrong class, isn’t it?