Несовместимые объявления методов в дублированных типах CLR / C ++ - PullRequest
0 голосов
/ 28 апреля 2020

У меня есть класс ниже в CLR / C ++.

MyDll.h:

namespace ASME {
    using namespace System::Runtime::InteropServices;
    using namespace System;

    ref class MyDll
    {
    public:
        [DllImport("Kernel32.dll")]
        static IntPtr LoadLibrary(String^ path);
    public:
        [DllImport("Kernel32.dll")]
        static bool FreeLibrary(IntPtr hModule);
    private:
        [DllImport("Kernel32.dll")]
        static IntPtr GetProcAddress(IntPtr hModule, String^ procName);

    public: static Delegate^ LoadFunction(IntPtr hModule, String^ functionName, Type^ type)
    {
        IntPtr functionAddress = GetProcAddress(hModule, functionName);
        if (functionAddress.ToInt64() == 0)
        {
            return nullptr;
        }
        return Marshal::GetDelegateForFunctionPointer(functionAddress, type);
    }
    };
}

UserAdd.h:

#include <libpq-fe.h>
#include "ASMeSDK.h"
#include "MyDll.h"

namespace ASME {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    using namespace System::Runtime::InteropServices;

    /// <summary>
    /// Summary for UserAdd
    /// </summary>
    public ref class UserAdd : public System::Windows::Forms::Form
    {
    public:
        UserAdd(void)
        {
            InitializeComponent();
        }
    private: System::Void UserAdd_Load(System::Object^  sender, System::EventArgs^  e)
    {
        IntPtr hModule = MyDll::LoadLibrary("DllPath");
        if (hModule == IntPtr::Zero)
           {
               MessageBox::Show("Failed to LoadDllIDCard ");               
           }
    }
    };
}

MyDll::LoadLibrary(String^ path) функция дублируется с LoadLibrary внутри Libloaderapi.h. Это потому, что * windows.h внутри "ASMeSDK.h" сторонней библиотеки.

Ошибка: Сбой операции метаданных LNK2022 (80131187): Несогласованные объявления методов в дублированных типах (типы: ASME.MyDll; методы: LoadLibrary): (0x06000001)

...