PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Error trying to call .NET DLL
Error trying to call .NET DLL
Iniciado por guest, 26,ago. 2017 19:58 - 4 respuestas
Publicado el 26,agosto 2017 - 19:58
Hi,

I'm trying call a procedure in a .NET DLL and am getting the following error.

Error at line 1 of Click BTN_Open_Device process.
Unable to create object ( assembly)

----- Technical Information -----

Project : Tourcube

WL call:
Process of 'Click BTN_Open_Device' (WINTest_Magtek.BTN_Open_Device), line 1, thread 0

What happened?
Unable to create object ( assembly)

Error code: 200005
Level: fatal error (EL_FATAL)

Dump of the error of 'wd200net4.dll' module (20.0.8.0).
Identifier of detailed information (.err): 200004
Additional Information:
EIT_PILEWL :
Click BTN_Open_Device (WINTest_Magtek.BTN_Open_Device), line 1
EIT_DATEHEURE : 26/08/2017 10:50:56

Help


I imported the DLL into my project into the .Net assembles area and it seemed to come in fine.

My code to call the procedure looks like this.

clMagtek is object MTPPSCRA

sModel is string=clMagtek.getDeviceModel()

Info(sModel)

Any ideas as to what might be going on? Things I'm missing. I don't typically use external .NET DLL's in my application (or object oriented methods) so I don't have a lot of experience with these things.

Any help would be greatly appreciated.

I am using WD 20 and the the DLL is used to connect to an external keypad device.

Thanks!

Steve
Publicado el 27,agosto 2017 - 20:07
Hi Steve,

Not sure it is related but the use of .Net assemblies has (in contradiction to the marketing) many limitations.
If your assembly is using any special types or advanced objects in its interfaces it is likely to fail and provide unexplainable runtime exceptions.
There's only one workaround (as I have had to) and that is to write your own C# assembly that translates your complex (or at .net runtime interpreted items) into the most basic types you can imagine.

Not sure this is your issue but it may well be the case...
As a side note I have been unable to integrate most of the client based standard MS SharePoint assemblies natively into WX...
Simply impossible... Guess SharePoint is not used in France at all ;-) Must be those weird Americans...

Cheers,

Peter
Publicado el 27,agosto 2017 - 21:09
Quote
Peter Holemans

Hi Steve,



Not sure it is related but the use of .Net assemblies has (in contradiction to the marketing) many limitations.

If your assembly is using any special types or advanced objects in its interfaces it is likely to fail and provide unexplainable runtime exceptions.

There's only one workaround (as I have had to) and that is to write your own C# assembly that translates your complex (or at .net runtime interpreted items) into the most basic types you can imagine.



Not sure this is your issue but it may well be the case...

As a side note I have been unable to integrate most of the client based standard MS SharePoint assemblies natively into WX...

Simply impossible... Guess SharePoint is not used in France at all ;-) Must be those weird Americans...



Cheers,



Peter

Thanks Peter. I suspected as much. Question: in your experience does this crash happen when you try to instantiate the Object or when you're calling it? I do know that the methods I want to use are fairly simple, I'm just not getting that far.

Steve
Publicado el 28,agosto 2017 - 08:25
Hi Steve,

It's not at instantiation as that always works. It is when doing a call to a method that returns something pretty complex (e.g; a site-, list or library collection in the case of SharePoint Client assemblies) or that has a lof of generics (stuff that is defined at runtime) that would crash the WX runtime.

The only work around I found was to write my own .Net assembly (VS / C#) as an intermediate one that would do all the complex/advanced handling stuff and return basic .Net types to the calling WX program only. It's a lot of overhead but it is the only way I could get a most of this stuff to work. Maybe somebody has better ideas to help you out...

Cheers,

Peter
Publicado el 28,agosto 2017 - 21:41
Hi Peter,

The original problem was that I had copied the DLL's into the project directory rather than the EXE directory, thanks, that part is solved now.

So, I'm able to communicate now with the simple methods but I'm stuck on a more complex one. I'll post another thread about that. Hopefully, it's possible to create the structure outlined in Windev but based on your feedback I'm not counting on it.

Steve