CodeStageGen

Blue Prism Code Stage compile errors and how to fix them

Updated 25 September 2026 · Every C# sample here compiles with the compiler that ships with Blue Prism.

When a Code Stage won't compile, Blue Prism shows you the compiler's message, which is often only loosely related to the actual mistake. This page lists the errors Blue Prism developers hit most, with the exact message text, so you can search for what's on your screen and find the fix.

Every message below was produced by the compiler Blue Prism itself uses (its own copy of Roslyn, in the Blue Prism install folder), so the wording matches what you'll see in Object Studio.

"is not declared" / "does not exist in the current context"

VB: BC30451: 'Regex' is not declared. It may be inaccessible due to its protection level. C#: CS0103: The name 'Regex' does not exist in the current context

The compiler can't find that name. There are three usual causes:

  1. A missing namespace import. Regex lives in System.Text.RegularExpressions, which isn't in a new object's imports. Add the namespace in Code Options → Namespace Imports on the Initialise page.
  2. A parameter name with the wrong spelling. Blue Prism turns a parameter called Input Text into the variable Input_Text: every character that isn't a letter or digit becomes an underscore. InputText and Input Text are both wrong:
    • CS0103: The name 'InputText' does not exist in the current context
    • Writing Input Text with the space gives CS1002: ; expected
  3. A property used on its own. Length by itself gives BC30451: 'Length' is not declared. It has to be Input_Text.Length.

"type or namespace could not be found" / "Type is not defined"

C#: CS0246: The type or namespace name 'JavaScriptSerializer' could not be found (are you missing a using directive or an assembly reference?) VB: BC30002: Type 'JavaScriptSerializer' is not defined.

The class exists, but the object doesn't import its namespace. Add it in Namespace Imports (System.Web.Script.Serialization in this case).

If the error names the namespace instead, the DLL is missing:

CS0234: The type or namespace name 'Script' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

Add the assembly (System.Web.Extensions.dll) in External References. Code usually needs both entries: the DLL in External References and the namespace in Namespace Imports.

"does not contain a definition for 'AsEnumerable'"

CS1061: 'DataTable' does not contain a definition for 'AsEnumerable' and no accessible extension method 'AsEnumerable' accepting a first argument of type 'DataTable' could be found (are you missing a using directive or an assembly reference?)

LINQ over a collection needs System.Data.DataSetExtensions.dll in External References and System.Linq in Namespace Imports. The same fix covers CopyToDataTable and Field<T>. See filtering a collection without a loop.

"Cannot apply indexing with [] to an expression of type 'DataTable'"

CS0021: Cannot apply indexing with [] to an expression of type 'DataTable'

A Blue Prism collection is a DataTable, not a list or an array, so Items[0]["Status"] doesn't work. Go through Rows:

C#
string status = Convert.ToString(Items.Rows[0]["Status"]);

Number errors: double vs decimal

CS0664: Literal of type double cannot be implicitly converted to type 'decimal'; use an 'M' suffix to create a literal of this type CS0266: Cannot implicitly convert type 'double' to 'decimal'. An explicit conversion exists (are you missing a cast?)

A Blue Prism Number is a decimal. Write literals with m (12.5m), and convert calculated doubles explicitly:

C#
double rate = 0.18;
Total = Convert.ToDecimal(100 * rate);

Better still, keep money in decimal from start to finish. double can't represent values like 0.1 exactly.

"A local or parameter named ... cannot be declared in this scope"

CS0136: A local or parameter named 'Input_Text' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

You declared a variable that Blue Prism already declared for you. Inputs and outputs from the Inputs and Outputs tabs are ready to use. Delete the string Input_Text = ...; line and assign to the existing variable.

Syntax errors from pasted using lines

CS1003: Syntax error, '(' expected, often followed by CS1026: ) expected

A using System.Text.RegularExpressions; line was pasted into the Code tab. The Code tab holds a method body, where using means something else. Delete the line and add the namespace in Namespace Imports.

Syntax errors from newer C# features

CS1525: Invalid expression term '=' (from x ??= "default";) CS1524: Expected catch or finally (from a switch expression)

Blue Prism's compiler supports C# 7.3. Code copied from a modern example that uses C# 8 or later features fails with confusing syntax errors, because the compiler doesn't recognise the new syntax at all. Rewrite with older syntax: if (x == null) x = "default";, and a switch statement instead of a switch expression. String interpolation ($"..."), tuples and pattern matching with is all work.

"Missing compiler required member ... RuntimeBinder"

CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'

The code uses dynamic (common in Office automation), and the object doesn't reference Microsoft.CSharp.dll. Add it in External References.

"member names cannot be the same as their enclosing type"

CS0542: ... member names cannot be the same as their enclosing type

Blue Prism compiles the object into a class named after the object, and each Code Stage into a method named after the stage. When a Code Stage has exactly the same name as the object, the method and the class clash. Rename the stage.

A missing DLL on the robot

The object compiles on your machine and fails on a robot with a reference error. Blue Prism loads referenced DLLs from its own install folder (usually C:\Program Files\Blue Prism Limited\Blue Prism Automate\). A third-party DLL must be copied there on every machine that runs the process, and that usually needs an administrator. Where the .NET Framework can do the job (for example JSON with JavaScriptSerializer), use it instead and there's nothing to deploy.

Related

More Code Stage guides