从我创建的引用 dll 调用方法时,我在 AX 2009 的自定义项目中收到一条消息。消息是错误执行代码对象未初始化。我的项目编译成功,并且 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();
}