EntryPointNotFoundException 尽管在 extern "C" 中有函数

我一直在尝试制作一个统一插件,将字符串连接到一个结构中。 问题是当我调用在 c++ 插件中创建的函数时,尽管它被包装在 extern“C”块中,但我仍然收到错误“EntryPointNotFoundException:concatenate”。

知道如何解决这个问题吗?

C++ 代码:

//concatenate.h
extern "C" __declspec(dllexport) twostrings concatenate(twostrings ts);

//concatenate.cpp
#include  "concatenate.h"
#include "pch.h"
#include "framework.h"
#include <iostream>

struct twostrings {
    std::string str1;
    std::string str2;
    std::string concatenated;
};

twostrings concatenate(twostrings ts) { 
    ts.concatenated = ts.str1 + ts.str2;  
    return ts; 
}

C# 代码:

[StructLayout(LayoutKind.Sequential,CharSet = CharSet.Ansi)]
    public struct twostrings
    {
        public string str1;
        public string str2;
        public string concatenated;
    };

    [DllImport(dll,EntryPoint = "concatenate")]
    public static extern twostrings concatenate(twostrings ts);

    twostrings data;

    // Start is called before the first frame update
    void Start()
    {
        data.str1 = "Hello ";
        data.str2 = "World!";
        data = concatenate(data);
        print(data.str1);
        print(data.str2);
        print(data.concatenated);
    }
SUPEROU2 回答:EntryPointNotFoundException 尽管在 extern "C" 中有函数

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/920.html

大家都在问