Using custom.net assembly in UIPath

code

#1

Hi, I’m trying to generate an custom package to UiPath but I had been impossible to find it in the imports section. In order to simplify I used an example from your page. So my code custom functionality is:

using System.Activities.Presentation.Metadata;

namespace CustomActivity
{
    public class Greeting : IRegisterMetadata
    {
        private static string _greetingMessage = "Hello :)";
    

    public static string GreetingMessage
    {
        get
        {
            return _greetingMessage;
        }
        set
        {
            _greetingMessage = value;
        }
    }

    public static string Greet()
    {
        return GreetingMessage;
    }

    public void Register()
    {
    }
}
}

I generated the package and save it in the UiPath package folder. It is able to find it in the UiPath (Manage Package) but I notice that it only appears when the check Filter Activities is unchecked.

I think this explain why I cannot add it in the import section but I don`t why my assembly doesn’t appear like an activity one.


#2

Hi Ross,

Just checked with very similar code and it worked without issues.

Steps taken:

  1. Build the dll in release.
  2. Create nuget package and place the dll there (under lib folder)
  3. Place nuget package in one of configured locations
  4. Import the package (Note: Filter Activities filters by nuget metadata ID field for .Contains(“Activities”), your package has “Activity” instead, that’s why it doesn’t see it initially).
  5. Put a writeline activity and manually typed fully qualified method name (in my case CustomActivityTest.Greetings.Greet). This forced UiPath to import the namespace. If it still shows the error, try restarting UiStudio.

My code below.
``using System;
using System.Activities.Presentation.Metadata;

namespace CustomActivityTest
{
///


/// Description of MyClass.
///

public class Greetings : IRegisterMetadata
{
public static string Greet()
{
return “Hello all!”;
}

	#region IRegisterMetadata implementation
	public void Register()
	{
	}
	#endregion
	
}

}``

As a sidenote - in the long run I’ve found it much easier to create activity accessors (a CodeActivity derived class that just calls the function). It makes importing much more reliable and also after that you can use both the classes themselves or activities (makes it easier for less technical designers).

Regards.


"Terminal Error: Field not found" when executing terminal session at a screen
#3

Hi, thanks very much for the fast response.

I changed the name the package and now it is able to be found by the manager but it seems I cannot use it. The dll was also build in Release mode.


#4

By other side, I also tested to create a new custom code activity, how can I use it in UiPath after I referenced its nuget package?


Code Activity - Creating my own algorithms
#5

Did you manage to go through this? I’ve the same problem