gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 07:55:35 25 4
gpt4 key购买 nike

我一直在尝试使用 Haxe 生成从用 C++/CLR 编写的 dll 中调用方法的 C# 代码。这个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吗?

提前致谢。

附言这些是 AudioClientSDK.dll 的一些属性:

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

另外,请注意,此 dll 可以在 Visual Studio 中使用 C# 而不会出现问题。

最佳答案

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

关于Haxe:如何在 haxe 代码中使用 .NET C++/CLI dll?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29612940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com