DLLs used in Batch processes

13 10 2011

I know this doesn’t have a lot to do with workflow in specific, but I struggled through this issue for a while without finding any other results on the net, so I’m posting it just in case somebody else struggles with the same issue.

We are running a batch job that makes use of a 3rd party DLL file. The batch process runs quite ok if we run it manually from the client, however as soon as we try and run it in batch mode it fails with a “CLR Error: cannot create object”.

The reason for this is that the batch server cannot find the DLL file to use. All the recommendations that I found to solve this error involved placing the DLL in the Global Assembly Cache (GAC) on the batch server. I understand that this would be the best way to overcome the error and should normally be the approach. However the DLL we have is not Strongly Named, so we received constant errors when trying to add it to the GAC. Unfortunately the vendor is not shipping a strongly named version of the DLL so a different approach has to be followed.

Where for client side execution of the DLL you need to place the file in C:\Program Files (x86)\Microsoft Dynamics AX\50\Client\Bin if you would like the server to access it, simply place it in C:\Program Files\Microsoft Dynamics AX\50\Server\[AOS name]\Bin on the batch server.

And like magic the batch job works. (Ok i had to restart the batch server AOS as well)

I hope this assists somebody in the near future.

Advertisements

Actions

Information

12 responses

11 06 2012
Meherab

Thanks.

Here I was with almost exactly the same problem. Copied the DLL to the Server\BIN folder, but still didn’t work.

Restarting the AOS was the magic bit…

21 03 2013
Budiyanto

Hi,
want to ask you mean restart the physical server or only the Dynamics Ax service?

I’m using WinSCP.dll it can run manually but when I scheduled in batch job can’t run at all, I tried to restart the AX service also not work.

Thanks

27 03 2013
Jonathanthan

Hi.

Normally just restarting the AOS should be sufficient. Are you using AX2009 or AX2012? Are you receiving any errors in the batch job log or the server’s event log?

28 03 2013
Budiyanto

I’m using AX2009, after i put the DLL on server folder and restart the AOS Service, i still not able to use the DLL until i use gacutil to register the DLL.
Actually i want to use WinSCP dll to send file to SFTP, when I try run manually it success to upload but when I schedule batch job it failed.

28 03 2013
Jonathan

Adding it to the GAC is a better idea if you are able to. However certain sites/clients won’t allow you access to do it. I really wrote the above post for when you are unable to add your DLL to the GAC.

9 04 2013
Sagar Laddha

None of the above steps are working for us :(. Created a DLL (3.5 framework), placed in Client’s bin, server’s bin, registered in GAC and restarted AOS. However, as soon as the DLL object instantiation code is hit, throws an exception, Object ‘CLRObject’ could not be created.

A a;
;
a = new A();

I am trying to call this DLL from a class for which RunOn is set to server. The idea is, I want the class to get called during workflow processing. For workflow, I need to make the class as RunOn Server.

Regards,
Sagar

16 04 2013
Roberta Freitas

Hi, I had this problem just a few days ago, we made another project using .net framework 2.0 and our DLL is now working =)

16 04 2013
Roberta Freitas

Hi, I had this problem just a few days ago, we made another project using .net framework 2.0 and our DLL is now working =)

12 11 2014
zinthozz

Hello. I’m working on AX2012 R3. I made a .NET Framework 3.5 dll to make calls on web services, but I can’t install it on the GAC because it’s not strongly named. When I use it on my client or running on server it works perfectly, but I receive a “Could not load assembly. The system cannot find the file specified” Exception when I run it on a batch job.

I noticed the DLLs created by Visual Studio projects are stored on a sub-folder of the Bin folder you described. This folder is VSAssemblies. The dll is updated each time I compile the project in the Server folder and the Client folder of the user who compiles the project, but the batch job can’t find it.

I’m using the System.Reflection.Assembly::Load method in order to get the DLL.

Can you help me with this? I have tried copying this DLL on the bin folder, but it doesn’t worked for me.

12 11 2014
Jonathan

Hi.

Do you perhaps have a separate AOS operating for the batch server?

12 11 2014
zinthozz

No. We have a single AOS.

13 11 2014
zinthozz

I just resolved my problem. I used Fusion Log Viewer to check the assembly calls.

I was looking for my DLL with a string “assembly.dll” on the Assembly::Load method.

Looks like on client or server execution there was no problem, but when the method was called from the CIL code of the batch job process, it was looking for something like “assembly.dll.DLL”. Obviosly this will not find anything.

I just removed the “.dll” extension on my call and the process could find the assembly.

Just for hint, the dll assembly must be generated on “Any CPU” platform on VS Studio 2010, because the CIL code was looking for a x64 version of the DLL, but the client/server was looking for a x86 version of the same dll.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: