我正在尝试调用Powershell中的Microsoft.AnalysisServices.Tabular.JsonScripter方法来自动为SSAS表格生成CreateOrReplace数据库脚本。但是,当我尝试执行以下代码时,我收到一条错误消息。
[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我检查了我安装了哪些版本(参考本文https://docs.microsoft.com/en-us/bi-reference/tom/install-distribute-and-reference-the-tabular-object-model),并在我的GAC文件夹中找到了这些版本。
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根据MS文档,没有版本17.0.0.0,我很困惑为什么这个方法需要这个版本,据我所知这个版本是不存在的。
有没有人在我的方法中遇到过类似的错误或发现了错误?
旁白:我既不精通Powershell也不精通.net,而且我对这个主题的理解也是基本的,所以请耐心等待。
我
发布于 2019-07-29 18:25:00
我已经通过卸载最新版本的AMO库并回退到以前的版本修复了这个问题。同事们一直在运行旧版本,可以很好地执行脚本,而我是唯一一个使用最新版本并遇到问题的人。
我仍然不确定问题的原因是什么,无论是库中的bug还是我工作的环境,但我很高兴它现在可以工作了。
所以,这是可行的:
v4.0_14.0.0.0__89845dcd8080cc91这不是:
v4.0_15.0.0.0__89845dcd8080cc91https://stackoverflow.com/questions/57223016
复制相似问题