Dynamics AX 2012 Error When Importing Modelstore
When importing model files from an ISV or another vendor you may trigger an error within Dynamics AX.
We recently faced this error in Dynamics AX 2012 when importing modelstore while working on a client account:
ERROR: Could not load file or assembly ‘C:\TEMP\demo1.axmodel’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
This is a common error and the solution can vary depending on your current environment. In this blog, we have compiled links to a variety of sources that we have found helpful to resolve this issue.
Microsoft employee Anup Shah wrote a blog on how to import model files using Export-AXModel. Using Powershell Version 2 as the blog recommends works in some cases, but not all. This is due to newer .Net being used when building the axmodel file instead of .NET 2.0 as explained here.
If the two above solutions do not work, you can follow the steps below to resolve the issue:
1.Download the iLSpy application.
Use iLSpy to see the .Net version used when the Axmodel file was built. This is optional and only if you are curious! This link will give you the ILSpy executable file.
Once downloaded, unzip it to a folder. In the folder you extracted the files to, you will them see the ILspy.exe file. This is the only file you need to launch the ILSpy application. Double click on ilSpy.exe to launch the application. In the ILSpy application, browse to your Axmodel file. You will then see the Runtime version is something other than 2.0 – like shown here – https://daxmusings.codecrib.com/2012/05/axutillibdll-issue-with-net-4.html
Then follow these steps (per the blog) to fix the issue –
Once downloaded and installed (it installs to C:\Program files (x86)\Microsoft\ILMerge) you can change the target version from the command prompt, like this:
ILMerge mymodel.axmodel /targetplatform:2.0 /out:mynewmodel.axmodel
You should now be able to import the new model into Dynamics AX.
If you need assistance or have any other questions, please reach out to the AX team at Stoneridge Software.