I found that to let AX use the .dll we need to,
1. Let AX know that .dll, so we can compile the code.
- Add reference
If the .dll is already added to GAC on the client machine, we can select it from the assembly list. Otherwise, we'll need to select the .dll file by browsing the file.
- If .dll is not in GAC on the client machine, we additionally need to copy the .dll file to the client/bin folder and restart the client so we can compile the code which consumes the .dll.
2. Let AX be able to find the .dll to consume it.
- If the code is run at server side, we need to make sure the .dll could be correctly consumed. So we need to either add that .dll to GAC on the server machine or add it to server/[InstanceName]/bin folder and restart the AOS.
- If the code is run at client side, we need to do the same to the client machine.
Once we've done above, the .dll should be able to be called by AX 2012.