我在AX 2009中的自定义项目中收到一条消息,当我从我创建的引用dll调用方法时。消息是执行未初始化的代码对象时出错。我已成功编译了我的项目,并在AOT中引用了dll。
尝试执行hostServices.Copy()时,MyClassExecuteCopy.copy()中发生错误
任何人都可以看到我收到此消息的原因有什么问题吗?
我缩短了此示例的代码,如下所示:
//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();
}
答案 0 :(得分:1)
发现要由数据初始化的问题。
结果hostServices.Copy()没有正确的值,导致dll内的错误或者没有返回任何方式是我在AX中收到的错误消息的结果。
更正同一个呼叫按预期处理后的数据。