cancel
Showing results for 
Search instead for 
Did you mean: 

Issues creating a code stage (works in Visual Studio)

ChrisHodgson1
Level 4
Hello, We have created a some code in Visual Studio that works as expected, but I'm having trouble getting it to work in an object. I have imported the DLL's and namespaces, but i'm still getting the following error: Description: Compiler error at line 17: Type or namespace definition, or end-of-file expected Has anybody any information as to how to get my code working in Blue Prism? My code is below: using Google.Cloud.Vision.V1; using System; namespace GoogleCloudSamples {     public class QuickStart     {         public static void Main(string[] args)         {             string credential_path = @"[PATH]";             System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credential_path);             var client = ImageAnnotatorClient.Create();             var image = Image.FromFile("[PATH 2]");             var response = client.DetectText(image);             foreach (var annotation in response)             {                 if (annotation.Description != null)                     Console.WriteLine(annotation.Description);             }         }     } } Thanks, Chris
7 REPLIES 7

ChrisHodgson1
Level 4
Apologies for the formatting, the preview post function isn't working and neither are carriage returns.

TolaniJaiye-Tik
Level 4
 Few pointers here Blue Prism doesn't permit defining a class, namespace or main method declaration in a code stage as they are not required. All you need is the content from the main method in your example dumped into the code stage. Defining a method or class is possible and only available under the Global Code, which can be found in the initialise page Any using statement will go under the Global Code [PATH2] or [PATH] isn't valid C# syntax so it will error out. If the [PATH2] or [PATH] are input variables to your program then you need to define the variables as an input in your code stage using the input tab & refer to it in your program as PATH2 and PATH accordingly. In general, variables are written in lowercase so path2 or path will be recommended Blue Prism runs any console operation in a  background mode so you won't be able to see the output form the console while your process is running Should in case you want to output annotation.Description in your program, you will need to define an output in the output tab of your code stage.

ChrisHodgson1
Level 4
Thank you Tolani.Jaiye-Tikolo   I have managed to get the code stages created as per the instructions and the namespace error is no longer happening. [PATH] and [PATH2] were just placeholders for the input variables so they are fine.   Unfortunately I'm now getting the following error:   Internal : Could not execute code stage because exception thrown by code stage: Could not load file or assembly 'Google.Cloud.Vision.V1, Version=1.1.0.0, Culture=neutral, PublicKeyToken=185c282632e132a0' or one of its dependencies. The system cannot find the file specified.   I have entered every DLL in the External References and the names of the relevant namespaces in the namespace entry so I'm unsure as to what the missing dependency might be.  The list of dependencies in Visual Studio have been added, and we've used ILSpy to review the ""Google.Cloud.Vision.V1"" DLL for a list of all other required DLL files, which have also been added, including all System DLL's. Would you be able to assist further?   Thank you,   Chris

ChrisHodgson1
Level 4
Is anybody able to provide any assistance with this issue?   Thanks,   Chris

DavidEdwards-Da
Level 5
Place the Google cloud vision DLL in the same folder as Automate.exe (symlink works also) or register it in the GAC

ChrisHodgson1
Level 4
Hi David, Thanks for the suggestion. I have already added my DLL files to same location as Automate.exe but still having issues. We've decided to run the code stage from an executable with command line parameters instead of trying to use the BP Code stages. Thanks, Chris

TolaniJaiye-Tik
Level 4
Importing external libraries can be a pain (e.g  Google.Cloud.Vision.V1) as you have to ensure all dependencies are well-taken care of and imported as well. I guess you are sorted now and good luck :).