Error on first .net function call

General discussion forum about all things Team Developer 7.x
Nils Jänicke
Germany
Posts: 12
Joined: 20 Sep 2017, 11:56
Location: Villingen-Schwenningen, Germany

Error on first .net function call

Post by Nils Jänicke » 21 Mar 2018, 16:40

Hi,

Maybe someone can help me. Since .Net Framework 4.5 there exists an easy to use zip file support in the .net framework. I want to use it in TD so I've used the .net wizard. On GAC I did not found the needed assemblies, so Ive used the option "Assembly File" to search for the system.io.compression classes. It seems that TD then searches the .dll files in the current folder, so I copied the files into the application folder and wrote a function to compress a file into a zip archive.
But the first call it shows an error "Open not found on class System.IO.Compression.ZipFile" on the command "Call __netBase.__Base_InvokeMethod_Overload2('System.IO.Compression.ZipFileExtensions', 'CreateEntryFromFile', payLoad, payLoad )" inside the generated function "System_IO_Compression_ZipFileExtensions_CreateEntryFromFile". The second call works fine, it compresses the file and writes a zip archive. Where is the problem? And can I change my code to get the dll from the .net framework folders without to copy them into my application folder?
You do not have the required permissions to view the files attached to this post.

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 471
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Error on first .net function call

Post by Dave Rabelink » 21 Mar 2018, 18:41

That is indeed strange.
The second time executing the code is fine.

Seems to be an initialization issue the first time, but "loads up" eventually so that the second time it works.
Dont know how to solve this, except a workaround to change the code so that there is no error messagebox.
Your code could call it twice then.

As for the GAC. The generated code uses

GAIL_LoadCustomAssembly(appDir, 'System.IO.Compression.FileSystem.dll')

you can change this to

GAIL_LoadGACAssembly( 'System.IO.Compression.FileSystem.dll' )
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Nils Jänicke
Germany
Posts: 12
Joined: 20 Sep 2017, 11:56
Location: Villingen-Schwenningen, Germany

Re: Error on first .net function call

Post by Nils Jänicke » 22 Mar 2018, 08:32

Thank you, with

Set bGailDisableAutoReportErrors = TRUE

I've got no errors and with

Set ZipArchive = System_IO_Compression_ZipFile_Open( 'test.zip', System_IO_Compression_ZipArchiveMode.Create )
Call ZipArchive.Dispose( )

at first it works. But

Call GAIL_LoadGACAssembly( 'System.IO.Compression.FileSystem.dll')

does not work. I think I should copy the dll files into the application folder and all it from there, but I don't want to get the folder by
Call SalFileGetCurrentDirectory( appDir )
because this folder may have changed by the application. I wold better use strArgArray[0] to get the application folder.
Maybe someone has a better idea why it does not work the first try.

Best regards
Nils

Nils Jänicke
Germany
Posts: 12
Joined: 20 Sep 2017, 11:56
Location: Villingen-Schwenningen, Germany

Re: Error on first .net function call

Post by Nils Jänicke » 22 Mar 2018, 11:11

I've tried to put this into my 64Bit application but it failes.
On the first call the function call of "If Not TriggerNetException( )" in function __Base_ReportError of the GailBase.apl crashes with an invalid memory error, removing the call of this function I get no zip file, the second call fails with the same error (method open not found in class).
Has anyone an idea how I can use this famous function within a x64 TD application?

Best regards
Nils

Return to “General Discussion”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests