Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从c++;使用其他外部DLL的项目? 我在OpenGL中开发了一个C++控制台应用程序,其中: #1使用一组其他DLL来运行。 #2由一组类组成,所有类都实例化在一个名为Run_class with one method的特定类中_C#_C++_Opengl_Dll - Fatal编程技术网

C# 如何从c++;使用其他外部DLL的项目? 我在OpenGL中开发了一个C++控制台应用程序,其中: #1使用一组其他DLL来运行。 #2由一组类组成,所有类都实例化在一个名为Run_class with one method的特定类中

C# 如何从c++;使用其他外部DLL的项目? 我在OpenGL中开发了一个C++控制台应用程序,其中: #1使用一组其他DLL来运行。 #2由一组类组成,所有类都实例化在一个名为Run_class with one method的特定类中,c#,c++,opengl,dll,C#,C++,Opengl,Dll,我为使dll.proj构建dll所做的工作:(下面的代码snipet) 我将所有类目录添加到dll的main.cpp中 此外,我还将所有外部dll添加到dll项目中 $(SolutionDir)/exLibs/GLM 我想用这个方法创建一个dll,并在.net内核中调用它。 在dll main.cpp文件中: #include "C:\Users\pouya\source\repos\Clonident\Project_Theis\RUNCLASS.h" #inclu

我为使dll.proj构建dll所做的工作:(下面的代码snipet)

  • 我将所有类目录添加到dll的main.cpp中

  • 此外,我还将所有外部dll添加到dll项目中

    $(SolutionDir)/exLibs/GLM

我想用这个方法创建一个dll,并在.net内核中调用它。 在dll main.cpp文件中:

#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\RUNCLASS.h"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\RUNCLASS.cpp"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Libs.h"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Shader.h"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Shader.cpp"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Camera.h"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Camera.cpp"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Model.h"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Model.cpp"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Texture.h"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Texture.cpp"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Window.h"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Window.cpp"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Light.h"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Light.cpp"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Mesh.cpp"
#include "C:\Users\pouya\source\repos\Clonident\Project_Theis\Mesh.cpp"

//C:\Users\pouya\source\repos\Clonident\Project_Theis

extern "C" __declspec(dllexport) void Take_snapShot(const void* pbuffer, size_t plenght, std::vector<float> angoli, std::string output_path, float Increase_scale, bool _x_axis, bool _Y_axis, bool _Z_axis)
{

    RUNCLASS RC(pbuffer, plenght, angoli, output_path, Increase_scale, _x_axis, _Y_axis, _Z_axis);
    RC.snapshot_wih_loop_in_memory_output_path();
}

通过构建C应用程序,我不会出错,所以我认为P/Unjk工作得很好,但是当我运行应用程序时,我有以下错误:

我不知道这意味着什么,我该怎么办

System.DllNotFoundException:'无法加载DLL “C:\Users\pouya\source\repos\Clonident\Release\Clonident\u DLL.DLL”或 它的一个依赖项:找不到指定的模块



正如它所说,您的DLL正在尝试链接(动态或静态):
C:\Users\pouya\source\repos\Clonident\Release\Clonident\u DLL.DLL
文件,但它不存在或不兼容(32/64位)。因此,您要么在某个地方使用绝对路径,要么只是没有将所需的所有DLL复制到您的项目中(您的可执行文件所在的位置),但正如您所看到的,我在dllImport标记中给出了完整路径,我不使用您的环境,所以我只是在这里猜测,但我会检查这些:1<代码>C:\Users文件夹可能有访问权限问题您的应用程序是否以管理员身份运行,您的用户文件夹是否具有共享访问权限?2.DLL是否与可执行文件(32/64位)3匹配。尝试将DLL移动到exe所在的位置(不考虑路径和/或使用相对路径)在过去存在此问题,静态DLL链接忽略路径4。您确定路径的语法正确吗(有些函数需要
/
一些
\\
一些
/
..5.问题是在DLL中还是在以后的某个DLL中?要检查这一点,您可以稍微重命名DLL,看看错误消息是使用新名称还是旧名称。@PooyaSobhanipour,您可以检查Clonident\u DLL.DLL的依赖关系吗?可能的异常原因可能是Clonident_DLL.DLL已就位,但找不到它的某些依赖项。您可以使用依赖项查看器检查DLL依赖项。
      [DllImport("C:\\Users\\pouya\\source\\repos\\Clonident\\Release\\Clonident_DLL.dll")]

        public static extern void Take_snapShot(System.String pbuffer, System.UInt32 plenght, Array angoli, string output_path, float Increase_scale, bool _x_axis, bool _Y_axis, bool _Z_axis);

 string filePath = @"C:\Users\pouya\source\repos\Clonident\Project_Theis\Models\MaxillaryPreScan.stl";

            byte[] my_file = File.ReadAllBytes(filePath);
            // list 
            float[] lst_num = new float[5] { 10, 40, 200, 800, 890 };


            Take_snapShot(Encoding.Default.GetString(my_file), (uint)my_file.Length, lst_num, "_dll_tst.jpg", 10, true, true, true);