1

I'm trying to call Microsoft.AnalysisServices.Tabular.JsonScripter methods within Powershell to automatically generate CreateOrReplace database scripts for SSAS Tabular. However, when I try to execute the following code I receive an error message.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular");
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Core");

$tab = "<Server>";
$dbId = "<Database>";
#$saveas = "C:\temp\{0}.dax" -f $tab.Replace('\', '_');


$as = New-Object Microsoft.AnalysisServices.Tabular.Server;
$as.Connect($tab);
$db = $as.Databases[$dbId];

[Microsoft.AnalysisServices.Tabular.JsonScripter]::ScriptCreateOrReplace($db);

Exception calling "ScriptCreateOrReplace" with "1" argument(s): "Could not load file or assembly 'Microsoft.AnalysisServices.Tabular.Json, Version=17.0.0.0, 
Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified."
At line:23 char:9
+         [Microsoft.AnalysisServices.Tabular.JsonScripter]::ScriptCrea ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FileNotFoundException

I checked which versions I have installed (referencing this article https://learn.microsoft.com/en-us/bi-reference/tom/install-distribute-and-reference-the-tabular-object-model) and found these versions in my GAC folder.

PS C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.AnalysisServices.Tabular> Get-ChildItem


    Directory: C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.AnalysisServices.Tabular


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       20.09.2018     12:45                v4.0_13.0.0.0__89845dcd8080cc91
d-----       11.09.2018     10:06                v4.0_14.0.0.0__89845dcd8080cc91
d-----       01.07.2019     16:38                v4.0_15.0.0.0__89845dcd8080cc91

According to MS documentation, there is no Version 17.0.0.0 and I am confused as to why the method needs this version, which does not exist to my knowledge.

Has anyone encountered a similar error or spots a mistake in my approach?

Sidenote: I am not proficient in neither Powershell nor .net and my understanding of the subject is basic, so please bear with me.

M

gmuehe
  • 51
  • 3
  • What is the contents of your C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.AnalysisServices.Tabular.Json directory? You listed .Tabular, not .Tabular.Json. Perhaps the .Json dll is missing? – Brandon McClure Jul 26 '19 at 20:49
  • Hi, thanks for the advice. Turns out falling back to a previous version resolved the issue... – gmuehe Jul 29 '19 at 10:25

1 Answers1

1

I have fixed the issue by uninstalling the latest version of the AMO libraries and falling back to the previous versions. Coworkers had been running the older version and could execute the script just fine while I was the only one on the newest version and encountered the issue.

I'm still unsure as to what the cause of the problem is, whether it is a bug in the library or due to the environment I work in, but I'm happy that it works now.

So, this works:

v4.0_14.0.0.0__89845dcd8080cc91

This doesn't:

v4.0_15.0.0.0__89845dcd8080cc91
gmuehe
  • 51
  • 3