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();
    if(batchforusers.prompt())
    {
        batchforusers.run();
    }
}

2>run method:

public void run()
{
   this.ExportExcelFile();
}

3>ExportExcelfile method:

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

    s= date2Str(today(),
      321,
      DateDay::Digits2,
      DateSeparator::None, // no separator
      DateMonth::Digits2,
      DateSeparator::None, // no separator
      DateYear::Digits4
      );

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";
try
    {
        permission = new FileIOPermission(fileName,#io_write);
        permission.assert();
        CommaIo = new CommaIo(fileName,#io_write);
    //Header
        commaIo.write("UserId","UserName","NetworkDomain","Company","Enabled","Alias");
        while select UserInfo
            {
            CommaIo .write(userInfo.id,userInfo.name,userInfo.networkDomain,userInfo.company,
userInfo.enable,UserInfo.networkAlias);
            }
        info ("file saved succesfuly");
    }
 catch (Exception::CLRError)
    {
        e = ClrInterop::getLastException();
        while (e)
            {
            info(e.get_Message());
            e = e.get_InnerException();
            }
        CodeAccessPermission::revertAssert();
    }

}

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.