Today I will post a solution for an error that happened when I was trying to export and import a model file to another server with different Windows Versions.
The title is big, but the solution is rather simple, although it took some time to discover the reason since I have no experience with AX infrastructure and PowerShell.
You probably will see this error when you export a model using Microsoft Dynamics AX Management Shell on Windows Server 2012 and then you try to install it on DAXMS but on Windows Server 2008.
This error occurs because on Window Server 2008, PowerShell starts using the old .NET Framework’s CLR which will be able to load it modules compiled on .Net Framework 3.5 (which uses CLR 2.0) but not .Net Framework 4.0 (which uses the CLR 4.0). This is perhaps a little surprising because Windows Server 2008 comes with .NET Framework 4.0 installed.
You can see exactly which version Powershell is using by command $PSVersionTable.
The screenshot above has been taken from a Windows server 2008, now let’s compare with Windows server 2012.
Notice the value of CLRVersion begins with “4.0”.
The solution is documented on the Microsoft’s Technet Website, but there is a small PowerShell script that will automatically create and place the necessary files.
Be aware that the script as shown below will overwrite existing .config files IF they have been edited by someone else.
Open Notepad and paste the following code:
$config_text = @" <?xml version="1.0"?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0.30319"/> <supportedRuntime version="v2.0.50727"/> </startup> </configuration> "@ $config_text| Out-File $pshome\powershell.exe.config $config_text| Out-File $pshome\powershell_ise.exe.config
Save it and then rename the file extension to .PS1
Ex.: CRLVersion4.ps1
Start PowerShell as an Administrator and then run the script, to make my life easier I saved my script on C:\Temp.
Now restart PowerShell and examine the value of CRLVersion.
*This post is locked for comments