Haxe:如何在haxe代码中使用.NET C ++ / CLI DLL?

时间:2015-04-13 18:56:19

标签: haxe

我一直在尝试使用Haxe生成C#代码,该代码从用C ++ / CLR编写的dll调用方法。这个dll被称为" AudioClientSDK.dll"

以下是我尝试的Haxe代码示例:

package hello;

class HelloWorld {

    static public function main():Void {
        var s = untyped __cs__("AudioClientCLR.AudioClientAPI.release()");
    }
}

正如你所看到的,我正在使用" Haxe magic"语法(我以前尝试过几乎导致相同问题的Haxe extern类)直接调用AudioClientSDK.dll中的release方法。 dll中的方法签名是:

public : void AudioClientCLR::AudioClientAPI::release()

但是,当我尝试编译此代码时,Haxe会抛出此错误:

haxe -cp src -cs out/CS -main hello.HelloWorld
haxelib run hxcs hxcs_build.txt --haxe-version 3103
c:\git\HelloHaxe\src\hello\HelloWorld.hx(6,16): error CS0103: The name
        'AudioClientCLR' does not exist in the current context
Compilation error
Native compilation failed
Error: Build failed

如果我尝试将AudioClientSDK.dll引用作为-net-lib或-net-std传递,则会出现以下错误:

haxe -cp src -cs out/CS -net-lib lib/CPP/x86/AudioClientSDK.dll -main hello.HelloWorld
File "ilMetaReader.ml", line 281, characters 36-42: Assertion failed
error 0x2

haxe -cp src -cs out/CS -net-std lib/CPP/x86/AudioClientSDK.dll -main hello.HelloWorld
Error: No .NET std lib directory with the pattern 'net-20' was found in the -net-std search path. Try updating the hxcs lib to the latest version, or specifying another -net-std path.

你们中的任何人都知道如何正确使用dll吗?

提前致谢。

P.S。这些是AudioClientSDK.dll的一些属性:

  • 目标框架:.NETFramework,Version = v4.0
  • 平台:Win32
  • 平台工具集:VisualStudio 2010(v100)
  • 使用MFC:在共享DLL中使用MFC
  • 公共语言运行时:公共语言运行时支持(/ clr)

另外,请注意,在Visual Studio中C#可以毫无问题地使用此DLL。

1 个答案:

答案 0 :(得分:0)

这似乎是一个错误。请尽快向haxe问题列表报告,并提供可下载链接到违规dll,它可能会包含在3.2最终版本中

相关问题