关于#dll#的问题,如何解决?(标签-C#)

问题遇到的现象和发生背景

C#调用C++编写的DLL失败
编译器 MSVC 2022

问题相关代码,请勿粘贴截图

CmakeLists

cmake_minimum_required (VERSION 3.8)
project(DLLVersion1)

add_library(TMP_dll SHARED TMP_dll.cpp)

c++ 编写的DLL代码,文件名为TMP_dll.cpp

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

extern "C" __declspec(dllexport) void TestCode(unsigned long long data)
{
    cout << data << endl;
}

c# 编写的调用代码

using System;
using System.IO;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace test1
{
    class Program
    {
        [DllImport("C:\\Users\\26327\\Desktop\\CTPDLL\\out\\build\\x64-Debug\\TMP_dll.dll")]
        public static extern void TestCode(UInt64 data);
        static void Main(string[] args)
        {
            TestCode(5125518666);
        }
    }
}


运行结果及报错内容

System.DllNotFoundException: 'Unable to load DLL 'TMP_dll.dll' or one of its dependencies: 找不到指定的模块。

找到解决方法了。出问题的是Debug生成的dll,改成Release生成,就不出错了。都是用的x64平台。
然而我依然不明白为啥,有没有兄弟能指教一下

大概率是x86 x64 问题。