Here below the code of the DLL i will use, just two classes:
- Log Helper: write something in the event viewer (could be useful for bug hunting)
- Program: the typical entry point for every .NET console application
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | using System; using System.Diagnostics; namespace BP.ExternalDll.Example { public class LogHelper { private readonly string _log; private readonly string _source; public LogHelper( string source, string log) { _source = source; _log = log; } public void LogWarning( string message) { try { CreateEventSource(); EventLog.WriteEntry(_source, message, EventLogEntryType.Warning); } catch (Exception) { // ignored // If you're here, it means you cannot write on event registry } } private void CreateEventSource() { if (!EventLog.SourceExists(_source)) { EventLog.CreateEventSource(_source, _log); } } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | namespace BP.ExternalDll.Example { public class Program { public static void Log() { string currentDirectory = System.Environment.CurrentDirectory; LogHelper _helper = new LogHelper( "BP.ExternalDll.Example" , "Test library" ); _helper.LogWarning(currentDirectory); } static void Main( string [] args) { Log(); } } } |
Don't try to put the file in other folders in your PC or organize the BP folder with subfolders: it will not work and don't argue with me that BP offers this functionality, IT DOESN'T WORK.
![]() |
I said: IT DOESN'T WORK |
In the code block you just have to write:
1 | Program.Log() |
My advice is to create always a BusinessDelegate class that holds all the methods you want to expose and create a single VBO action for every method in the BP, this will enhance testability and maintenance. That's all folks!
How custom classes can be passed to other stages in Blueprism?
ReplyDeleteHi Anil, this is a good point.
DeleteI think you need to hide the class complexity and create a stateless helper to manipulate your classes.
BP should not be aware of classes.
Best regards