PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → Error intitializing DotNetDelegate
Error intitializing DotNetDelegate
Started by steve erts, Oct., 17 2017 11:07 PM - 3 replies
Posted on October, 17 2017 - 11:07 PM
Hi,

I'm trying to deploy some code that I have working on my local dev machine but when I run it on the production server. I get this error:

Error at line 24 of Global Procedure GP_MagTekOpenDevice process.
DotNetDelegate function called.
Unable to create WL.CWLDelegate_void_OnCardRequestCompleteEvent_string> object (C:\My Projects\Tourcube22 - Clean\Exe\Tourcube\Tourcube.dll assembly)
Unable to open E:\TourcubeRoot\Heritage\EXE\Tourcube.dll assembly
Error returned by .NET Framework:
Could not load file or assembly 'file:///E:\TourcubeRoot\Heritage\EXE\Tourcube.dll' or one of its dependencies. The system cannot find the file specified.
Unable to open assembly

If you look at the bolded section windev is trying for some reason to use the local path from my dev machine to create the DotNetDelegate.

Here is code that intitializes the delegate


// declare delegate

CardRequestCompleted is OnCardRequestCompleteEvent dynamic
CardRequestCompleted = DotNetDelegate(GP_MyRequestCompleted,"OnCardRequestCompleteEvent")

//register delegate

clMagtek.add_onCardRequestComplete(CardRequestCompleted)


Any idea what I'm doing wrong? How to get around this?

Thanks!
Posted on October, 18 2017 - 1:39 AM
All my DLL's are in the EXE directory on the production server and I can run the sample code for the device I am trying to communicate with and all works fine. I can not for the life of me figure out why the error is referencing a directory path on my dev machine though. It's like the imported assembly has a reference in it somewhere that I can not see.
Posted on October, 18 2017 - 9:47 AM
Steve,

I have seen this error when the version of .NET on the target machine differs from the one the assembly is compiled for. On the other hand you say some sample code IS working okay? Using the very same tourcube.dll?

The reference to your paths is coming from Windev of course. The assembly itself cannot know this.
If I am right you also need an extra dll with the same name as your executable. Windev creates this when using .net assemblies, only pcsoft knows why.
Posted on October, 18 2017 - 7:20 PM
Thanks Arie, your suggestion was very helpful and I was able to get my code working but I do believe there is a bug in windev and what I had to do does not really make sense.

I ended up creating a directory on my production server that had same name as my project directory on my dev machine and I put the "ghost" dll that Windev generates in there (exe name+ dll "tourcube.dll") and that got it working.

I can't imagine this is intentional but we see to be ok for now.