Errors during BatchJob processing

1] Unable to construct an object from the class BatchForUsers in the batch framework. Make sure that the X++ code has been compiled to Microsoft .NET Framework CIL, and that the constructor does not require any parameters.

2] Microsoft.Dynamics.Ax.Xpp.ErrorException: Exception of type ‘Microsoft.Dynamics.Ax.Xpp.ErrorException’ was thrown.

at Dynamics.Ax.Application.BatchRun.runJobStaticCode(Int64 batchId) in BatchRun.runJobStaticCode.xpp:line 34

at Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) in BatchRun.runJobStatic.xpp:line 13

at BatchRun::runJobStatic(Object[] )

at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)

at BatchIL.taskThreadEntry(Object threadArg)

Iam getting the above errors while running a batch job
Can any one help to resolve this error…?

The error already told you what to do. Did you follow the advice?

Hi Martin…Yes I followed the advice…but the error not yet resolved

Did you compile X++ before generating CIL? Did both end without any error?
Can you show us code of BatchForUsers class?

Yes Martin they both ended with out errors…coming to code of BatchForUsers class it has nine methods …which method code i need to show you…?

1>main method:

public static  void main(Args _args)
    BatchForUsers batchforusers ;
    batchforusers = new BatchForUsers();

2>run method:

public void run()

3>ExportExcelfile method:

public void ExportExcelFile()
    FileIOPermission permission;
    CommaIo CommaIo;
    UserInfo userInfo;
    System.Exception e;
    int time ;
    str s ;
    str fileName;
    time = timenow();

    s= date2Str(today(),
      DateSeparator::None, // no separator
      DateSeparator::None, // no separator

fileName = @"D:\\Security Weaver\\Users_"+s + "_" +num2str0(time div 3600,2,0,0,0) + "_" 
+num2Str0(time mod 3600 div 60,2,0,0,0) + "_" +
          num2Str0(time mod 3600 mod 60,2,0,0,0)+".csv";
        permission = new FileIOPermission(fileName,#io_write);
        CommaIo = new CommaIo(fileName,#io_write);
        while select UserInfo
            CommaIo .write(,,userInfo.networkDomain,,
        info ("file saved succesfuly");
 catch (Exception::CLRError)
        e = ClrInterop::getLastException();
        while (e)
            e = e.get_InnerException();


Do you have overridden constructor?

What code do you have at line 34 of BatchRun.runJobStaticCode()? batchClass = batch.object()?

If you’re unable to find the problem statically, debug the code to see it at runtime.