Question

I am receiving a message in my custom project within AX 2009 when calling a method from a referenced dll I created. The message is Error executing code object not initialized. I have my project compiled successfully and the dll is referenced in the AOT.

The error occurs in MyClassExecuteCopy.copy() when trying to perform hostServices.Copy()

Can anyone see any issues as to why I would be receiving this message?

I shortened the code for this example as follows:

//classDeclaration
class MyClassExecute extends RunbaseBatch
{
    MyDll.Win.HostServices                    hostServices;
    MyDll.Data.InputParameters                inputParams;
    MyDll.Test.Data.ResultSummary           resultSummary;
}

//MyClassExecute.initLiabraries
public void initLiabraries()
{
    ;
    new InteropPermission(InteropKind::ClrInterop).assert();

    hostServices = new MyDll.Win.HostServices();
    inputParams = new MyDll.Data.InputParameters();

    CodeAccessPermission::revertAssert();
}

////////////////////////////////////////////

class MyClassExecuteCopy extends MyClassExecute
{
}

//MyClassExecuteCopy.copy   - Exception occurs on resultSummary line with "Error executing code: copySomething     object not initialized"
void copy()
{
    new InteropPermission(InteropKind::ClrInterop).assert();

    //Exception occurs when executing line below with "Error executing code: copySomething object not initialized"
    resultSummary = hostServices.Copy();

    CodeAccessPermission::revertAssert();
}

//////////////////////////////////////////////

class CreateCopy extends Runbase
{
}

//CreateCopy.copySomething
public client server static void copySomething()
{
    MyClassExecuteCopy            myClassExecuteCopy;
    ;
    new InteropPermission(InteropKind::ClrInterop).assert();
    myClassExecuteCopy.initLiabraries();
    myClassExecuteCopy.copy();
    CodeAccessPermission::revertAssert();
}
Was it helpful?

Solution

Found the issue to be initialized by data.

As a result hostServices.Copy() did not have the correct values and either resulting in an error within the dll or returned nothing either way was the result of the error message i was receiving within AX.

After correcting the data that same call processed as expected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top