Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 4 Monaten, 4 Wochen
Letzter Beitrag:
vor 4 Monaten, 3 Wochen
Beteiligte Autoren:
steve erts, Peter Holemans

Error trying to call .NET DLL (solved)

Startbeitrag von steve erts am 26.08.2017 17:58

Hi,

I am using WD 20 to connect to an external keypad device. I've imported the .NET DLL into my project with no issues but when I try to to create the Object I get 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 : 27/08/2017 10:33:45

Help




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.

Thanks!

Steve

Antworten:

Re: Error trying to call .NET DLL

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

von Peter Holemans - am 27.08.2017 18:07

Re: Error trying to call .NET DLL

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

von steve erts - am 27.08.2017 19:09

Re: Error trying to call .NET DLL

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...

UPDATE 12:08 -> Reviewing your initial question it may be that the Assembly is not accessible from your test environment (WDTest - Move the DLL to the Exe directory of your project) or from your executable (Move the DLL in the same directory as your exe).

Also make sure the Assembly DLL is marked as executable (Moving .Net assemblies around blocks them from execution on most Windows (Server) systems). To do so: right click the DLL and check the different security tabs.

Alternatively you could add the DLL as well to the GAC (Global Assembly Cache) so it becomes available for any program on your computer. Assemblies in the GAC are always approved for execution.
See also: https://docs.microsoft.com/en-us/dotnet/framework/app-domains/gac

Cheers,

Peter

von Peter Holemans - am 28.08.2017 06:25
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

von steve erts - am 28.08.2017 19:41
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.