Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting past an error Multiple ambiguous overloads found for "Save"

Tags:

powershell

I am trying to save an xml object using the save method. I receive the error:

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

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

I know that by running only one save the program runs without error. So I believe the multiple calls of the method are causing the issue but I am not familiar with argument.

What can I do to placate the Powershell console, it was running in Powershell ISE but I am not sure where to look now.

Thanks for the read. Please let me know if you have any questions and I will do my best to provide the correct info.

like image 350
Hopeless Programmer Avatar asked Sep 26 '22 14:09

Hopeless Programmer


1 Answers

Define the parameter $fileLocation as a string, so which Save overload to call is not ambiguous.

function Save($config,[string]$fileLocation) 
{ 
 $config.Save($fileLocation) 
}
like image 80
dugas Avatar answered Oct 13 '22 01:10

dugas