2
votes

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();
}
1
In the referenced DLL, can you trace the copySomething object? My first instinct is that you need to call something else in MyDll.Win.HostServices for Copy() to work properly, similar to how you need to call initLiabraries in AX. - kingofzeal
i was asked to research the issue and do not have access to the code within 'copy' but i did trace back the data being used within the process and found it to be invalid resulting in copy to either error or return nothing. Thanks for the response. - Brendan

1 Answers

1
votes

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.