..Microsoft.AnalysisServer.Server.."Cannot created Activex Component"

Recently, I worked on a scenario, where a .NET application was trying to use SQL Server Analysis Services Management object as a COM component. The short description of the objective was:

1. .NET application uses Microsoft.AnalysisServices.Server component to create the Server object to connect SQL Server Analysis Services.

2. The code snippet used, to load Microsoft.AnalysisServices.Server component into the application domain, is

objAS = CreateObject("Microsoft.AnalysisServices.Server")

The code above works fine in x86 environment, however the code fails to execute, giving the following error message, under 64 bit environment:

can't load Microsoft.AnalysisServer.Server in 64bit environemnt - "Cannot create Activex Component"

After investigation, I found that, the issue can happen under the following when, for Analysis Management Object (AMO) component for SSAS 2008, we do not install the components properly so that the 32 bit version exe can load 32 bit version of AMO and 64 bit version exes can load 64 bit AMO components

There are two possible we can get around to loading issue of the assembly. We can either load the corresponding assembly as:

oAssembly = Assembly.Load("Microsoft.AnalysisServices, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL")

or we can also load the corresponding assembly as:

oAssembly = Assembly.LoadFile("C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.AnalysisServices.DLL")

Now if we create the Server object, as below, we should have a problem.

oAS = oAssembly.CreateInstance("Microsoft.AnalysisServices.Server")

If the above workarounds does not work for some scenarios, then you can use the following technique:

Step 1:

Download and Install AMO (Analysis Management Object) component (s) from SQL Server 2008 Feature packs:
https://www.microsoft.com/en-us/download/details.aspx?id=16978

Microsoft® SQL Server® 2008 R2 Analysis Management Objects  Analysis Management Objects (AMO) is a .NET Framework object model that enables software developers to create client-side applications to manage and administer Analysis Services objects.

Audience(s): Customer, Partner, Developer

X86 Package(SQLSERVER2008_ASAMO10.msi)
X64 Package (SQLSERVER2008_ASAMO10.msi)
IA64 Package(SQLSERVER2008_ASAMO10.msi)

for 32 bit x86 option and for 64 bit x64 bit option

Step 2:

Register the DLL

Register the .NET Assembly manually into the registry this way:
C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies>C:\windows\microsoft.net\Framework64\v2.0.50727\regasm.exe Microsoft.AnalysisServices.DLL (for 64 bit)
C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies>C:\windows\microsoft.net\Framework\v2.0.50727\regasm.exe Microsoft.AnalysisServices.DLL (for 32 bit)

Reference
https://www.advancedinstaller.com/forums/viewtopic.php?f=2&t=7837

For .NET Framework 2.0 the 32-bit version of "Regasm.exe" is installed in this folder:
Code: Select all C:\windows\microsoft.net\Framework\v2.0.50727\regasm.exe
and the 64-bit version in this folder:
Code: Select allC:\windows\microsoft.net\Framework64\v2.0.50727\regasm.exe
So you have to use the respective regasm exe and the respective DLL version with the appropriate path for 32 bit and 64 bit version respective

Step 3:

Verify the component in the registry for COM interoperability

After this, the component should show you under register as:
Computer\HKEY_CLASSES_ROOT\Microsoft.AnalysisServices.Server

Step 4:

Write code to create COM Component in .NET code.

Now that you have the DLL, you can use the code:
oAS = CreateObject("Microsoft.AnalysisServices.Server")

 

After this step, you should have see the error message any more.

 

Hope this helps in future AMO programming scenario, where you need to troubleshoot AMO Assembly ioading issues.

 

Tips:

Use Fusion logging technique, to understand, why might be having the assembly loading issues.

 

Happy Analysis Management Object programming....