I am trying to invoke c sharp code in invoke activity.
System.Windows.Forms.MessageBox.Show(“Hello from UiPath!”);
But I am getting below error.
Invoke Code: No compiled code to run
error CS0234: The type or namespace name ‘MessageBox’ does not exist in the namespace ‘System.Windows.Forms’ (are you missing an assembly reference?) At line 1
System.Windows.Forms namespace, which contains the MessageBox class, is not accessible from your Invoke Code activity. You can resolve this issue by explicitly adding a reference to the System.Windows.Forms assembly in your Invoke Code activity.
Here’s how to do it:
1.Open the Invoke Code activity in UiPath.
2.In the Properties panel on the right, locate the “Imports” section.
3.Click on the “Add Imports” link.
4.In the dialog that appears, enter “System.Windows.Forms” in the “Namespace” field.
5.Click the “Add” button.
6.Now, you should see “System.Windows.Forms” listed under the “Imports” section in the Properties panel.
You can use MessageBox.Show("Hello from UiPath!"); in your Invoke Code block without any errors.
1.Check Imports: Make sure the using System.Windows.Forms; statement is at the beginning of your C# code within the “Invoke Code” activity. It should be before any other code.
Restart UiPath:Sometimes, UiPath Studio might not pick up new assembly references immediately. Try restarting UiPath to see if the issue persists.
3.Ensure that the “Invoke Code” activity is placed in a sequence where it can be executed in the correct order. The error could be related to the sequence of execution in your workflow.
4.Close and reopen your UiPath project to refresh any cached information. @rds0511
Can you try to Reinstall System.Windows.Forms Package: Sometimes, package references can become corrupted. Try removing the System.Windows.Forms package from your UiPath project, save your project, and then re-add it. Ensure that the package is installed correctly
Studio Update : Ensure you’re using the latest version of UiPath Studio. Older versions may have compatibility issues with certain libraries.