I'm trying to call Microsoft.AnalysisServices.Tabular.JsonScripter in my Powershell script to automatically generate CreateOrReplace database scripts for SSAS Tabular. But I keep getting the following error.
Exception calling "ScriptCreateOrReplace" with "1" argument(s): "Could not load file or assembly
'Microsoft.AnalysisServices.AppLocal.Tabular.Json, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
or one of its dependencies. The system cannot find the file specified."
At C:\Desktop\json.ps1:10 char:1
+ [Microsoft.AnalysisServices.Tabular.JsonScripter]::ScriptCreateOrRepl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileNotFoundException
Here is the code Im testing:
Import-Module SqlServer
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular");
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Core");
$tab = "server";
$dbId = "database";
$as = New-Object Microsoft.AnalysisServices.Tabular.Server;
$as.Connect($tab);
$db = $as.Databases[$dbId];
[Microsoft.AnalysisServices.Tabular.JsonScripter]::ScriptCreateOrReplace($db);
the assemblies load the following:
GAC Version Location
--- ------- --------
True v4.0.30319 C:\windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.AnalysisServices.Tabular\v4.0_14.0.0.0__8...
True v4.0.30319 C:\windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.AnalysisServices.Core\v4.0_14.0.0.0__8984...
so the assemblies should be recognized, but yet its complaining about them. What am i supposed to do in this case?