Search code examples
haxe

How to import Net Framework classes as sourse files to use at project?


From here https://github.com/HaxeFoundation/HaxeManual/wiki/Haxe-C%23 I've learned:

Haxe can directly load .NET assembly files (.DLL) and convert its type definitions for use as Haxe types. To load a .NET assembly, use -net-lib library.dll compiler option. Haxe will then automatically parse types defined in that assembly file and make them available for import as Haxe types.

Fine, I want import Forms.DLL. Not haxe -net-lib C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll nor haxelib -net-lib C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll made something.

Then I've found that https://groups.google.com/forum/#!topic/haxelang/DS8AXeWxiTA . Guy here uses

haxe -cp src -cs F:/_dev/CSTest2/CSTest2 -D net-ver=40 -D net-std=C:\Windows\Microsoft.NET\Framework\v4.0.30319\ -main Main -net-lib Accessibility.dll@std -net-lib System.Drawing.dll@std -net-lib System.Windows.Forms.dll@std

I suppose its compile.hxml file setting. But... Its compile file. I still getting error of unknown "import cs.system.windows.forms.Form;". So its like should already exist at my source files before compilation starts.

Here is my current compile.hxml which I've tried to compile:

-main Main
-cp src
-cs bin
-D net-ver=40
-D -net-std=C:\Windows\Microsoft.NET\Framework\v4.0.30319\
-net-lib C:\Windows\Microsoft.NET\Framework\v4.0.30319\Accessibility.dll@std 
-net-lib C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll@std
-net-lib C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Drawing.dll@std

And got huge amount of errors similar to that example:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll @ cs.system.windows.forms.ImageList (Finalize):1: character 0 : Invalid override on field 'Finalize': class has no super class C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll @ cs.system.windows.forms.ImageList:1: character 0 : Defined in this class

So where is I'm wrong. Or what should I add/edit to start using Net Framework at haxe project?


Solution

  • The finalizer errors you're getting are a known issue with -net-lib, see #5241. Fortunately, there's been a fix in October which is included in Haxe 4.0.0-preview.2. The fix is not included in the latest stable release (3.4.4).