【问题标题】:Can't call IFileSystemOperations.Open() method in powershell script无法在 powershell 脚本中调用 IFileSystemOperations.Open() 方法
【发布时间】:2018-05-30 19:10:01
【问题描述】:

我将一个名为 _adlsFileSystemClient 的 DataLakeStoreFileSystemManagementClient 实例传递给一个 powershell 脚本,然后我希望从那里执行以下操作。

_adlsFileSystemClient.FileSystem.Open(_adlsAccountName, filePath))

以下是我的 Powershell 脚本

param([System.Object]$dlsFSMC)
Add-Type -Path C:\Users\..\source\repos\tester\packages\Microsoft.Azure.Management.DataLake.Store.2.4.0-preview\lib\net452\Microsoft.Azure.Management.DataLake.Store.dll"
$strm = $dlsFSMC.FileSystem.Open(<name>,<path>)   

名称和路径在这些地方我有实际的字符串值。 我收到如下错误消息。

方法调用失败,因为 [Microsoft.Azure.Management.DataLake.Store.FileSystemOperations] 确实 不包含名为“打开”的方法。

_adlsFileSystemClient.FileSystem.Open(_adlsAccountName, filePath)) 在 Visual Studio 中完美运行时,我很困惑为什么会出现上述错误。

【问题讨论】:

    标签: c# .net powershell azure


    【解决方案1】:

    Openextension method,要调用它,您需要调用静态函数并传入对象。

    param([System.Object]$dlsFSMC)
    Add-Type -Path C:\Users\..\source\repos\tester\packages\Microsoft.Azure.Management.DataLake.Store.2.4.0-preview\lib\net452\Microsoft.Azure.Management.DataLake.Store.dll"
    $strm = [Microsoft.Azure.Management.DataLake.Store.FileSystemOperationsExtensions]::Open($dlsFSMC.FileSystem, <name>,<path>)   
    

    【讨论】:

    • 非常感谢斯科特。我已经为此绞尽脑汁了几个小时。
    猜你喜欢
    • 2017-07-12
    • 2018-10-23
    • 2021-05-13
    • 2021-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-06
    • 1970-01-01
    相关资源
    最近更新 更多