Hello, I’m trying to add a Custom Class so I can use custom methods in UiPath.
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace CSharpLibrary
{
public class DataManipulation
{
public DataManipulation()
{
}
public string GetStringFromDictionary(Dictionary<string, object> dict, string key, string name)
{
if (name == null || name == String.Empty)
{
name = "Config";
}
try
{
return dict[key].ToString();
}
catch (KeyNotFoundException knfE)
{
throw new Exception("The Key <" + key + "> was not found in the dictionary: <" + name + ">. " + knfE.Message);
}
catch (ArgumentException argE)
{
throw new Exception("The Key <" + key + "> was not found in the dictionary: <" + name + ">. " + argE.Message);
}
catch (Exception E)
{
throw new Exception("Unexpected error while searching the key <" + key + "> in the dictionary: <" + name + ">. " + E.Message);
}
}
}
}
I tried to follow the steps in this post:
And I tried other different things, like changing the target framework to 4.8 or different ones and naming the Id of the package so it ends in “.Activities”.
The most I achieved was being able to create a variable in UiPath of the mentioned class:
FYI, as your custom library is compiled for NetStandard2.0, it might be trouble in Windows-Legacy compatible project.
So you need to use this custom library in Windows (.net5) compatible OR re-compile it as net461 target.
The following is a sample in windows(net5) compatible. It works well in my environment.
Thank you very much for everything! And for the advice!
At the end I could use it, I’m having a little trouble when adding the reference, as it seems at the beginning that it is not recognized (as I showed in the error message), and also in the imports section you mentioned for some reason the BindCSharpLibrary appeared twice. I had to delete variables, uninstall the package, delete the imports, and try again and it worked.