如何导入 Net Framework 类 作为源文件以在项目中使用?
How to import Net Framework classes as sourse files to use at project?
从这里https://github.com/HaxeFoundation/HaxeManual/wiki/Haxe-C%23我了解到:
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.
好的,我要导入 Forms.DLL。 haxe -net-lib C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll
和 haxelib -net-lib C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll
都没有做出来。
然后我发现 https://groups.google.com/forum/#!topic/haxelang/DS8AXeWxiTA 。这里的人使用
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
我想它的 compile.hxml 文件设置。但是...它的编译文件。我仍然收到未知错误“import cs.system.windows.forms.Form;”。所以在编译开始之前它应该已经存在于我的源文件中。
这是我尝试编译的当前 compile.hxml:
-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
并且出现了大量类似于该示例的错误:
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
所以我哪里错了。或者我应该如何 add/edit 开始在 haxe 项目中使用 Net Framework?
您遇到的终结器错误是 -net-lib
的一个已知问题,请参阅 #5241. Fortunately, there's been a fix in October which is included in Haxe 4.0.0-preview.2。该修复程序 未 包含在最新的稳定版本 (3.4.4) 中。
从这里https://github.com/HaxeFoundation/HaxeManual/wiki/Haxe-C%23我了解到:
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.
好的,我要导入 Forms.DLL。 haxe -net-lib C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll
和 haxelib -net-lib C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll
都没有做出来。
然后我发现 https://groups.google.com/forum/#!topic/haxelang/DS8AXeWxiTA 。这里的人使用
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
我想它的 compile.hxml 文件设置。但是...它的编译文件。我仍然收到未知错误“import cs.system.windows.forms.Form;”。所以在编译开始之前它应该已经存在于我的源文件中。
这是我尝试编译的当前 compile.hxml:
-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
并且出现了大量类似于该示例的错误:
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
所以我哪里错了。或者我应该如何 add/edit 开始在 haxe 项目中使用 Net Framework?
您遇到的终结器错误是 -net-lib
的一个已知问题,请参阅 #5241. Fortunately, there's been a fix in October which is included in Haxe 4.0.0-preview.2。该修复程序 未 包含在最新的稳定版本 (3.4.4) 中。