cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in code stage

NaveenRPA
Level 4

Blue Prism Trial 

I hope this message finds you well. I am reaching out to report a bug I encountered while using the Code Stage in Blue Prism.

While working with the Code Stage, specifically when attempting to set a DataTable containing a Binary type row to an out collection, I encountered the following error:

“Internal : Could not execute code stage: Conversion from type ‘Byte()’ to type ‘String’ is not valid.”

To provide context, below is a snippet of the sample code I was using:

var dt = new DataTable();
dt.Columns.Add("Column1",typeof(Byte[]));
dt.Rows.Add(File.ReadAllBytes(@"C:\Windows\Web\Wallpaper\Windows\img0.jpg"));
outParam=dt;

I would appreciate it if you could investigate this issue further and provide guidance or a solution to resolve it. If you require any additional information or assistance from my end, please feel free to ask.

https://community.blueprism.com/t5/Digital-Exchange/Bug-in-code-stage-unable-set-binary-type-in-Collection/td-p/109177

i am using Blueprism trail version 7.2.1.7446 (x64) and .net version is 4.8.9181

Thank you.

Best regards,
Naveen.

4 REPLIES 4

John__Carter
Staff
Staff

Try changing the 3rd line to

DataRow dr = dt.NewRow();

dr[0] = File.ReadAllBytes(@"C:\Windows\Web\Wallpaper\Windows\img0.jpg");

dt.Rows.Add(dr);

NaveenRPA
Level 4

@John__Carter  - i tried your suggestion but still i am getting the same error.

John__Carter
Staff
Staff

Paste this and edit the file path:

<process name="__selection__Test 01" type="object" runmode="Exclusive"><stage stageid="57db7a3f-19b0-413b-9344-1bdde3c4c4c9" name="Code1" type="Code"><subsheetid>547d73f1-3eae-47a0-937b-73d09803abe7</subsheetid><loginhibit /><display x="15" y="30" /><inputs><input type="collection" name="cInput" expr="[Coll1]" /><input type="text" name="Path" expr="[Path]" /></inputs><outputs><output type="collection" name="cOutput" stage="Coll1" /></outputs><code><![CDATA[DataRow dr = cInput.NewRow();
dr[0] = System.IO.File.ReadAllBytes(Path);
cInput.Rows.Add(dr);
cOutput = cInput;]]></code></stage><stage stageid="f8333324-3c8d-4c26-b364-beeef21e2afd" name="Coll1" type="Collection"><subsheetid>547d73f1-3eae-47a0-937b-73d09803abe7</subsheetid><loginhibit /><display x="90" y="30" /><datatype>collection</datatype><private /><alwaysinit /><collectioninfo><field name="Field1" type="binary" /></collectioninfo></stage><stage stageid="436bb0d0-4439-47f7-8538-1460016ab2dc" name="Path" type="Data"><subsheetid>547d73f1-3eae-47a0-937b-73d09803abe7</subsheetid><loginhibit /><display x="90" y="-15" /><datatype>text</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="28effe8e-b2d4-4f5b-8938-84391ca48b93" name="Path" type="Calculation"><subsheetid>547d73f1-3eae-47a0-937b-73d09803abe7</subsheetid><loginhibit /><display x="15" y="-15" /><onsuccess>57db7a3f-19b0-413b-9344-1bdde3c4c4c9</onsuccess><calculation expression="" stage="Path" /></stage></process>

NaveenRPA
Level 4

Hi @John__Carter ,

I tried your code it is working fine but i want this without defining input collection.

I tried same code in BP 6.10.5 which working fine, only problem with BP 7.2.1.