gpt4 book ai didi

powershell - 解决错误 为 "Save"找到多个不明确的重载

转载 作者:行者123 更新时间:2023-12-01 02:02:30 24 4
gpt4 key购买 nike

我正在尝试使用 save 方法保存一个 xml 对象。我收到错误:

Multiple ambiguous overloads found for "Save" and the argument count: "1".


Function Save-File($config, $fileLocation){
#saves to file
$config.Save($fileLocation)
}

我知道通过只运行一个 save 程序运行没有错误。所以我相信该方法的多次调用导致了这个问题,但我不熟悉参数。

我能做些什么来安抚 Powershell 控制台,它在 Powershell ISE 中运行,但我不知道现在在哪里看。

感谢阅读。如果您有任何问题,请告诉我,我会尽力提供正确的信息。

最佳答案

将参数 $fileLocation 定义为字符串,因此调用哪个 Save 重载是明确的。

function Save($config,[string]$fileLocation) 
{
$config.Save($fileLocation)
}

关于powershell - 解决错误 为 "Save"找到多个不明确的重载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34950866/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com