简体   繁体   English

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

[英]Haxe: How to use a .NET C++/CLI dll in haxe code?

I've been trying to use Haxe to generate C# code that calls methods from a dll written in C++/CLR. 我一直在尝试使用Haxe生成C#代码,该C#代码从以C ++ / CLR编写的dll调用方法。 This dll is called "AudioClientSDK.dll" 该dll被称为“ AudioClientSDK.dll”

Here is an example of the Haxe code I'm trying: 这是我正在尝试的Haxe代码的示例:

package hello;

class HelloWorld {

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

As you can see I'm using "Haxe magic" syntax (I previously tried Haxe extern classes that resulted pretty much in the same problems) to directly call the release method within the AudioClientSDK.dll. 如您所见,我正在使用“ Haxe magic”语法(我以前尝试过Haxe extern类,导致了几乎相同的问题)直接在AudioClientSDK.dll中调用release方法。 The method signature inside the dll is: dll中的方法签名为:

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

However, when I try to compile this code, Haxe throws this error: 但是,当我尝试编译此代码时,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

If I try to pass the AudioClientSDK.dll reference as -net-lib or -net-std I get these errors: 如果我尝试将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.

Do any of you know how to correctly use the dll? 你们中有人知道如何正确使用dll吗?

Thanks in advance. 提前致谢。

PS These are some properties of the AudioClientSDK.dll: PS这些是AudioClientSDK.dll的一些属性:

  • Targeted framework: .NETFramework,Version=v4.0 目标框架:.NETFramework,Version = v4.0
  • Platform: Win32 平台:Win32
  • Platform Toolset: VisualStudio 2010 (v100) 平台工具集:VisualStudio 2010(v100)
  • Use of MFC: Use MFC in a Shared DLL MFC的使用:在共享DLL中使用MFC
  • Common Language Runtime: Common Language Runtime Support (/clr) 通用语言运行时:通用语言运行时支持(/ clr)

Also, please note that this dll can be used without problems from C# in Visual Studio. 另外,请注意,可以从Visual Studio中的C#正常使用此dll。

This seems like a bug. 这似乎是一个错误。 Please report it ASAP to the haxe issue list, with a downloadable link to the offending dll, and it might get included inyo the 3.2 final release 请尽快将其报告给haxe问题列表,并提供有问题的dll的可下载链接,并且它可能会包含在3.2最终版本中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM