xsharp.eu • Transferring large VO project to X# - Page 3
Page 3 of 5

Transferring large VO project to X#

Posted: Fri May 07, 2021 7:32 am
by Fabrice
Hi Stefano,
sorry to read that.
.. I will check that asap !

Fab

Transferring large VO project to X#

Posted: Fri May 07, 2021 7:44 am
by Chris
Hi Glen,

As Wolfgang said, please do read all the articles under the "Migrating apps from VO to X#" topic that I pointed you out to earlier, they contain extremely valuable information, especially for someone who now starts the porting process.

It is mentioned in the 2nd sample there, that because in .Net it is not possible to have an access/assign pair and a method with the same name (Font and Font() in the Control class of the VOSDK), the Font access/assign has been renamed to ControlFont in X#, so you just need to change "Font" to "ControlFont".

About the PCALL problem, this is more tricky, but simplest and most efficient solution is to just define a _DLL function for it, which should work also in VO:

_DLL FUNCTION IsWow64Process(hHandle AS PTR, plWow64Process AS LOGIC PTR) AS LOGIC:KERNEL32.IsWow64Process

....

LOCAL lIsWow64 AS LOGIC
? IsWow64Process(GetCurrentProcess() , @lIsWow64)
? lIsWow64

Transferring large VO project to X#

Posted: Fri May 07, 2021 8:32 am
by Fabrice
Hi Stefano,
I've to rebuild and had some glitches
so, I've Pushed some corrections to the repository: https://github.com/X-Sharp/FabTools

Mainly, I've done some corrections due to 2.8 :) ... Ambiguity between a function or a method call
and a trouble (!?) with the DotnetZip NuGet package: What I've done here was to suppress the package from the four Zip projects, and re-install: It is ok now, so I hope the link has been corrected.

Please, keep me informed if you still have some troubles with it.

Fab.

Transferring large VO project to X#

Posted: Fri May 07, 2021 8:57 am
by Karl-Heinz
HI Glen,

f you want to stay with the the dynamic calls, there are two options:

1. keep the untyped hfunc ptr and use

Code: Select all

PCallNative <LOGIC> ( hFunc , GetCurrentProcess() , @lIsWow64 ) 
instead of

Code: Select all

PCall(hFunc ,GetCurrentProcess(), @lIsWow64)

Code: Select all

FUNCTION PCE_Is64BitOS() AS LOGIC
LOCAL hModule AS PTR
LOCAL hFunc AS PTR
LOCAL lIsWow64 AS LOGIC

hModule := GetModuleHandle( String2Psz( "kernel32" ) )
hFunc := GetProcAddress( hModule, String2Psz( "IsWow64Process" ) )

IF ! hFunc == NULL_PTR
	PCallNative <LOGIC> ( hFunc , GetCurrentProcess() , @lIsWow64 ) 
ENDIF
RETURN lIsWow64   
2. or change hFunc to a typed function ptr

Code: Select all

FUNCTION PCE_Is64BitOS() AS LOGIC
LOCAL hModule AS PTR
LOCAL hFunc AS __IsWow64Process PTR
LOCAL lIsWow64 AS LOGIC

hModule := GetModuleHandle( String2Psz( "kernel32" ) )
hFunc := GetProcAddress( hModule, String2Psz( "IsWow64Process" ) )

IF ! hFunc == NULL_PTR
	PCALL( hFunc, GetCurrentProcess(), @lIsWow64 ) 
ENDIF
RETURN lIsWow64 

STATIC FUNCTION __IsWow64Process( hProcess AS PTR , Wow64Process AS LOGIC PTR ) AS LOGIC 

    RETURN FALSE	
regards
Karl-Heinz

Transferring large VO project to X#

Posted: Fri May 07, 2021 10:00 am
by Chris
Hi Fabrice,
Fabrice wrote:Hi Stefano,
I've to rebuild and had some glitches
so, I've Pushed some corrections to the repository: https://github.com/X-Sharp/FabTools

Mainly, I've done some corrections due to 2.8 :) ... Ambiguity between a function or a method call
and a trouble (!?) with the DotnetZip NuGet package: What I've done here was to suppress the package from the four Zip projects, and re-install: It is ok now, so I hope the link has been corrected.

Please, keep me informed if you still have some troubles with it.
Unfortunately there still seem to be issues. Not sure if you saw my message in the dev forum, but there are problems with references, for example the FabPaintLib project references the CLR2 versions of System.Drawing and System.Windows.Forms, also the 2.1 version of the X# runtime is referenced. This is from FabPaintLib.xsproj :

Code: Select all

    <Reference Include="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <Name>System.Drawing</Name>
      <AssemblyName>System.Drawing.dll</AssemblyName>
    </Reference>
    <Reference Include="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <Name>System.Windows.Forms</Name>
      <AssemblyName>System.Windows.Forms.dll</AssemblyName>
    </Reference>
    <Reference Include="VOWin32APILibrary, Version=2.1.0.0, Culture=neutral, PublicKeyToken=a967d8055360a7b9">
      <Name>VOWin32APILibrary</Name>
      <AssemblyName>VOWin32APILibrary.dll</AssemblyName>
      <SpecificVersion>False</SpecificVersion>
      <Private>True</Private>
      <HintPath>C:Program Files (x86)XSharpRedistVOWin32APILibrary.dll</HintPath>
    </Reference>
    <Reference Include="XSharp.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=ed555a0467764586">
      <Name>XSharp.Core</Name>
      <AssemblyName>XSharp.Core.dll</AssemblyName>
      <SpecificVersion>False</SpecificVersion>
      <Private>True</Private>
      <HintPath>C:Program Files (x86)XSharpAssembliesXSharp.Core.dll</HintPath>
    </Reference>
    <Reference Include="XSharp.RT, Version=2.1.0.0, Culture=neutral, PublicKeyToken=ed555a0467764586">
      <Name>XSharp.RT</Name>
      <AssemblyName>XSharp.RT.dll</AssemblyName>
      <SpecificVersion>False</SpecificVersion>
      <Private>True</Private>
      <HintPath>C:Program Files (x86)XSharpAssembliesXSharp.RT.dll</HintPath>
    </Reference>
Also the reference to DotNetZip in FabZip cannot be resolved, although this could be a local problem, my PC probably hates NuGet packages same as its master :)

Edit: also the file Ionic.Zip.dll is not available, while it is referenced in the Fab_Zip_1_52j_Test project, But maybe this needs to be downloaded externally anyway?

Transferring large VO project to X#

Posted: Fri May 07, 2021 10:24 am
by Fabrice
Hi Chris,
Thx, I will check that and make the corrections.
The DotNetZip is a NuGet package, not installed per default, I will the steps to Restore the package.
and Ionic.Zip is the "old" version of DotNetZip, I have removed that reference in the latest push.

Thx again
Fab

Transferring large VO project to X#

Posted: Fri May 07, 2021 1:36 pm
by Chris
Hi Fabrice,
Fabrice wrote: Thx, I will check that and make the corrections.
The DotNetZip is a NuGet package, not installed per default, I will the steps to Restore the package.
and Ionic.Zip is the "old" version of DotNetZip, I have removed that reference in the latest push.
Thanks for looking into it! About the DotNetZip library, isn't it much simpler if you just include the dll and add a reference to it in the project? Or is this library not allowed to be redistributed freely?

Transferring large VO project to X#

Posted: Fri May 07, 2021 6:47 pm
by ic2
Hello Fabrice,

...or you can use System.IO.Compression, e.g.:

using (ZipArchive zip = ZipFile.Open(zipPath, ZipArchiveMode.Create))
zip.CreateEntryFromFile(@"d:LargeFile.txt,,LargeFile.txt)

I used this class a few years ago when FabZip couldn't handle (because of VO) files >2GB.

Dick

Transferring large VO project to X#

Posted: Fri May 07, 2021 8:06 pm
by GlenT
Thanks Chris. I will get to the articles and digest them. The Font one is obvious now you show it to me. I should have seen that one,

I'll implement the _DLL function and see how far that takes me.

Cheers

Glen
Chris wrote:Hi Glen,

As Wolfgang said, please do read all the articles under the "Migrating apps from VO to X#" topic that I pointed you out to earlier, they contain extremely valuable information, especially for someone who now starts the porting process.

It is mentioned in the 2nd sample there, that because in .Net it is not possible to have an access/assign pair and a method with the same name (Font and Font() in the Control class of the VOSDK), the Font access/assign has been renamed to ControlFont in X#, so you just need to change "Font" to "ControlFont".

About the PCALL problem, this is more tricky, but simplest and most efficient solution is to just define a _DLL function for it, which should work also in VO:

_DLL FUNCTION IsWow64Process(hHandle AS PTR, plWow64Process AS LOGIC PTR) AS LOGIC:KERNEL32.IsWow64Process

....

LOCAL lIsWow64 AS LOGIC
? IsWow64Process(GetCurrentProcess() , @lIsWow64)
? lIsWow64

Transferring large VO project to X#

Posted: Fri May 07, 2021 8:08 pm
by GlenT
Thanks Wolfgang. I've out it on the top of my (very long) list.

Cheers

Glen
wriedmann wrote:Hi Glen,
OLE/COM as it worked in VO does not works anymore in X#.
Please see the X# help, "Migrating apps from VO to X#", "Example 5 - The Email Client Example".
That works (I have done it myself).
Wolfgang