Wednesday, May 26, 2010

Microsoft Dynamics AX 4.0 and Analysis Services 2008

Using Microsoft Dynamics AX 4.0 with SQL Server 2008 or SQL Server 2008 R2 produces a couple of errors that are easily fixed.


First, when trying to Transfer or Process a Cube Instance, the following error occurs.


Method 'setServer' in COM object of class '{A4D49012-F5A5-4d86-8978-863A41277677}' returned error code 0x80070002 () which means: Could not load file or assembly 'Microsoft.AnalysisServices, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.



One or more required client components that support OLAP analysis are not installed on this computer. For details on the required components, in Administrator Help, see Set up OLAP reporting.








The ax32.exe binary is hard coded to reference the Microsoft.AnalysisServices .NET assembly version 9.0.242.0, but this can be fixed with a binding redirect.


Navigate to %programfiles%\Microsoft Dynamics AX\40\client\bin\ and create a file named ax32.exe.config with the following contents.


<?xml version="1.0" encoding="utf-8" ?> 
<configuration>
  <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
      <dependentAssembly> 
        <assemblyIdentity name="Microsoft.AnalysisServices" publicKeyToken="89845dcd8080cc91" culture="neutral"/> 
        <bindingRedirect oldVersion="0.0.0.0-9.9.0.0" newVersion="10.0.0.0"/> 
      </dependentAssembly> 
    </assemblyBinding> 
  </runtime> 
</configuration>






This forces the ax32.exe to use the Microsoft.AnalysisServices .NET assembly version 10.0.0.0 instead.

Even with this in place, the following error still occurs.

One or more required client components that support OLAP analysis are not installed on this computer. For details on the required components, in Administrator Help, see Set up OLAP reporting.

In class OLAPServerControlAMO the method AMOAvailable checks to see if components are present before creating a new OLAPAMOManager class.  The code looks for a registry signature only found with 9.0.242.0 and needs to be updated to look for newer Microsoft.AnalysisServices .NET assembly signatures.  The following updated method works.

static boolean AMOAvailable()
{
    boolean     valid = false;
    #winapi
    container reg   = connull();
    int       handle;
    str       keyValue;

    // This method checks to see if the registry contains a key from the Server object
    // of the AMO dll. If it does, it checks the key value against the version of the
    // object that is to be used. If it is a match, then AMO is considered available
    // and true is returned.
    handle  = WinAPI::regOpenKey(#HKEY_CLASSES_ROOT, 'Microsoft.AnalysisServices.server\\Clsid', #KEY_READ);
    if (handle)
    {

        reg     = WinAPI::regGetValue(handle, '');
        keyvalue = conpeek(reg,1);
        if (keyValue == '{554BBCA3-925F-4797-9460-2421A8CD7030}')
            valid = true;
        WinAPI::regCloseKey(handle);
    }

    handle = WinAPI::regOpenKey(#HKEY_LOCAL_MACHINE, 'SOFTWARE\\Classes\\Installer\\Assemblies\\Global', #KEY_READ);
    if (handle)
    {
        reg = WinAPI::regGetValue(handle, 'Microsoft.AnalysisServices,fileVersion="10.0.2531.0",version="10.0.0.0000",culture="neutral",publicKeyToken="89845DCD8080CC91",processorArchitecture="MSIL"');
        if (conlen(reg) &gt; 0)
            valid = true;

        reg = WinAPI::regGetValue(handle, 'Microsoft.AnalysisServices,fileVersion="10.50.1600.1",version="10.0.0.00000",culture="neutral",publicKeyToken="89845DCD8080CC91",processorArchitecture="MSIL"');
        if (conlen(reg) &gt; 0)
            valid = true;

        WinAPI::regCloseKey(handle);
    }

    return valid;
}

Notice that it checks for both the Analysis Services 2008 (10.0.2531.0) and Analysis Services 2008 R2 (10.5.1600.1) assembly.

With these two fixes in place and the proper components installed, Transfer and Process should work.