cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Custom DLL creation.

LeonStroschein
Level 3
Hi All,
I'm using VS2019 and C# to create a custom DLL to parse a Flat File and return a DataTable.
I'm using the latest developer version of BP (6.6.015260) I have chosen .Net 4.7 as the target framework.
My DLL references System, System.Core, System.Data, System.Xml. I have tried Platform Target of all 3 types Any Cpu, x86, x64.
I have copied the DLL to the BP program folder, added the Namespace and Reference to it.
I get the same error everytime I try to run it.
"Internal : Could not execute code stage because exception thrown by code stage: Could not load file or assembly 'BPTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."

Any idea what I'm doing wrong? Any resource that explains how to create and use custom DLLs with BP?
Thanks for any help!

------------------------------
Leon
------------------------------
11 REPLIES 11

Carl__Carter
Staff
Staff
Hi Leon,

As you have already copied your custom DLL to the Blue Prism install folder, there are 2 things I would recommend to fix this;

  1. Check that the External Reference in the Business Object to your DLL includes the full file path, or ensure the PATH Environment Variable (in Windows) contains the Blue Prism installation folder. Information on this is here http://portal.blueprism.com/customer-support/support-center#/path/1140188762
  2. Restart Blue Prism if you haven't since copying the DLL to the install folder or updating the PATH variable.


Blue Prism supports .NET V4.7 for external code references, so this is ok.



------------------------------
Carl Carter
Developer Program Manager
Blue Prism
Europe/London
------------------------------

Hi Carl,
First, Thank You for getting back to me!

I have the DLL in the BP folder. I have the full DLL path in the Exteranl References.  I did not have the BP app folder in the Env PATH, but I do now.

So I have tried the restart process, which for me is finding the BP tray icon, right clicking and choose restart.  I have also tried completely closing out of BP. That does not work either.  Thing is that the code validation works, and seems to be picking up the exposed methods in the DLL, unless that is not being checked by that validation.  I have got this to work just once, and that was after a PC restart.  So I am going to try that again, and see what happens.  I have some questions below...

1. Should the target Platform be "Any Cpu", "x86", or "x64"?  My assumption was "x64"
2. Do I need to increment the assembly/file version with each new build? My assumption would be no.
3. Do I need to rename the DLL for each new version? My assumption would be no.
4. Do I need to remove and re-add the DLL in the business object external references everytime I update the DLL?  My assumption would be no.

Thanks,
-Leon



------------------------------
Leon
------------------------------

Hi Leon,

Normally closing all sessions of automate.exe and reopening is enough for Blue Prism to recognize the dll once it has been dropped into the install folder.

In answer to you questions;

  1. Should the target Platform be "Any Cpu", "x86", or "x64"?  My assumption was "x64"It should match the underlying operating system and the version of Blue Prism installed, however I've never had any problems with using the 'Any CPU' option.

  2. Do I need to increment the assembly/file version with each new build? My assumption would be no.No - but consider coding standards.

  3. Do I need to rename the DLL for each new version? My assumption would be no.No - but consider coding standards.

  4. Do I need to remove and re-add the DLL in the business object external references everytime I update the DLL?  My assumption would be no.No - but consider coding standards.

Do you receive the same error message since adding the Env Var PATH and restarting Blue Prism?

------------------------------
Carl Carter
Developer Program Manager
Blue Prism
Europe/London
------------------------------

Thank you again!

When I'm doing rapid development, especially this type, I don't rename or version the DLL until it has a new set of functionality and is stable.  It's just a 1 man shop here. So I was just asking because I wanted to make sure that BP wasn't caching or ingesting the updated to another local or DB based on some naming.

I rebooted, and I still can't get it to work.  The error is so generic, I can't tell whats not right.  I'm going to add some screen shots of the C# project to help.

The exposed used method is ParseFlatFile()

------------------------------
Leon
------------------------------

Hi Leon,

I have created third party DLL files in my project to to SFTP operations. I copied DLL file to the Blueprism installation directory and provided only dll file name in External references instead of complete path. I suggest you to give it a try as I face similar exception while coding.

Thanks,
Ravi Teja

------------------------------
Ravi Teja
RPA Developer
Accenture
Asia/Kolkata
------------------------------

Hi Ravi,
Thanks for the suggestion!  I will try using a relative path, I didn't because most information I have read said to use an absolute path to the DLL.

One of the issues I'm facing is when I update the DLL to a new version of code without changing the name or assembly version (done during development).  Currently the only way I have been able to get the DLL to load, without error, after an update, is to change the name of it and update that in the External References in the BP business object.  But that goes against how Carl is telling me the system works.  Though I should be able to determine a little more soon, as I have a few more updates to make this week.  If the DLL or something about it is being cached in some way by BP, that information needs to be made available to us developers, because not knowing makes the development process of custom DLLs an exercise in frustration.

------------------------------
Leon
------------------------------

This is normally a problem free activity which I have personally done many times over the last 10 years.

​​I manage the developer program here at Blue Prism, but my background is development; predominantly VB. 

If you want to make available your VB project on Dropbox or other cloud storage, I can take a look to id your problem, but I do stress this is not an issue with our software.

------------------------------
Carl Carter
Developer Program Manager
Blue Prism
Europe/London
------------------------------

Hi Carl,
Still having issues.  I just updated my DLL with a new Type, and copied over the existing DLL in the BP application folder.  Same name, same assembly version.  Now I wire everything up and run the process.  I get a the following error 
"Internal : Could not execute code stage because exception thrown by code stage: Could not load type 'CTR.BluePrism.LotteryIntercepts.LotteryInterceptProcessor' from assembly 'CTR.BluePrism.LotteryIntercepts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."
I even tried renaming the DLL, and updating the External References, the restarting BP.  No luck same thing. (I will try a full PC restart next... and then try an assembly version change)

So BP ran the initial method that I had all ready working but when it came to the new method, it fails with the above error.  Just like it was using the old DLL with out the new method.  To make things even more interesting, if I validate the code, it checks out OK, so it's definitely picking up the new DLL and it's new methods.  It's just at run time, that I get the errors.

I'm looking for suggestions on what I could be doing wrong, or what could be wrong with my setup.  Any additional suggestions would be helpful!

------------------------------
Leon
------------------------------

I noticed in an earlier post, you mentioned compiling it as x64. Even if you grab a 64-bit version of the installer, Automate.exe still runs as a 32-bit executable and will require 32-bit dll files to be loaded. Try recompiling it as x86 and see if it works.

------------------------------
Ami Barrett
Sr Product Consultant
Blue Prism
Plano, TX
------------------------------