Error intitializing DotNetDelegate

Startbeitrag von steve erts am 17.10.2017 21:07

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!

Antworten:

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.

von steve erts - am 17.10.2017 23:39
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.

von Arie - am 18.10.2017 07:47
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.

von steve erts - am 18.10.2017 17:20
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.