cancel
Showing results for 
Search instead for 
Did you mean: 

Error in code stage : the out parameter must be assigned to before control leaves the current method

DavidOku
Level 2
Hello,
I am new  to blue prism and this is my first question here. I am having this issue in my code stage. although  found a similar issue in this post  here
the solution was only able to take out one of the error messages.
Originally , I had two errors in my code stage saying " the out parameter must be assigned to before control leaves the current method".
I have assigned the parameters at the top of code just as it was stated in that.
the parameter errorMessage is now okay but the parameter InstanceFullFilePath still has the error 
: The out parameter 'InstanceFullFilePath' must be assigned to before control leaves the current method.

Here is my code below
try {
errorMessage = "";
InstanceFullFilePath = "";
string InstanceFile = InstanceFileNameWithoutExtension+Path.GetExtension(TemplateFileNameWithExtension);
string templateFilePath = Path.Combine(TemplateDirectory,TemplateFileNameWithExtension);
InstanceFullFilePath = Path.Combine(InstanceDestinationFolderPath,InstanceFile);
File.Copy(templateFilePath,InstanceFullFilePath,true);

} catch (Exception ex) {
errorMessage = ex.Message;

}​

36782.png
1 REPLY 1

DavidOku
Level 2
Hello guys,
Thank you . I found the solution to the problem ..phew!!
I discovered that I had to assign InstanceFullFilePath in the Catch stage as seen in the modified code, typically what this means is any where the code exits all out parameters in the code stage must be assigned to something.... Phew! Great learning ... Thanks guys.

try {
errorMessage = "";
string InstanceFile = InstanceFileNameWithoutExtension+Path.GetExtension(TemplateFileNameWithExtension);
string templateFilePath = Path.Combine(TemplateDirectory,TemplateFileNameWithExtension);
InstanceFullFilePath = Path.Combine(InstanceDestinationFolderPath,InstanceFile);
File.Copy(templateFilePath,InstanceFullFilePath,true);


} catch (Exception ex) {
errorMessage = ex.Message;
InstanceFullFilePath = "";

}​