How can I use returns std::vector<std::vector<double>> function dll C ++ to c# marshling?

reza1: <p>I searched in my new C ++, but unfortunately there is information on how I can integrate the following function using the external “C” declspec (dllexport) and call this function in C ++. I did.</p>
<pre><code class="lang-auto">extern "C" declspec(dllexport) std::vector&lt;std::vector&lt;double&gt;&gt; cdecl PrepareFaceBank(std::string Path)
</code></pre>
<p>But unfortunately I received the following error, I have no idea, thank you very much for your help?</p>
<pre><code class="lang-auto">extern "C" declspec(dllexport) std::vector&lt;std::vector&lt;double&gt;&gt; cdecl PrepareFaceBank(std::string Path)

{
    try
    {
        //load model (if it has been loaded any where else just comment it)
        FaceModule = torch::jit::load(FaceModulePath);

        std::cout &lt;&lt; "Model loaded successfully" &lt;&lt; std::endl;
        //Disable grad for high performance beacuase this is pretrained model
        torch::NoGradGuard no_grad;
        //an array to save all persons tensor in it
        std::vector&lt;torch::Tensor&gt; embeddings;
        //itterate through facebank directory
        for (const auto&amp; name : get_folderPath(Path))
        {
            std::cout &lt;&lt; "name :" &lt;&lt; name.filename() &lt;&lt; ": " &lt;&lt; '\n';
            
            //array to save all of the photos of each person
            std::vector&lt;torch::Tensor&gt; embs;
            //clear befor itterate through all photos of each person
            embs.clear();
            //int a = 0;
            for (const auto&amp; fileName : get_filenames(name))
            {
                //std::cout &lt;&lt;'\t' &lt;&lt; fileName &lt;&lt; std::endl;

                Mat image = imread(fileName);
                
                /* Display if needed:
                cv::namedWindow("Display window");// Create a window for display.
                cv::imshow("Display window", image);
                cv::waitKey(0);
                */
                
                embs.push_back(ProcessFrame(image));
                //empty cache 
                image.release();
                //how many photos each person have
                //std::cout &lt;&lt; '\t' &lt;&lt; a++ &lt;&lt; std::endl;
            }

            //number of photos in data base for this person
            //std::cout &lt;&lt; "embs size: " &lt;&lt; embs.size() &lt;&lt; "\n";
            //convert vector to tensorlist and the calculate the Mean value for all of the photos of each person
            torch::Tensor embedding; // 1*512
            torch::TensorList tensor_list{ embs };
            embedding = torch::mean(torch::cat(tensor_list), 0);
            
            embeddings.push_back(embedding);
        }
        std::vector&lt;double&gt; EachPersonVec;
        std::vector&lt;std::vector&lt;double&gt; &gt; retValue;
        for (const auto&amp; n : embeddings)
        {
            
            EachPersonVec.clear();
            for (int i = 0; i &lt; 512; i++)
            {
                EachPersonVec.push_back(n[i].item().to&lt;double&gt;());
            }
            
            retValue.push_back(EachPersonVec);
        }
        //number of persons in database
        std::cout &lt;&lt; "embeddings size : " &lt;&lt; embeddings.size() &lt;&lt; "\n";
        
        return retValue;
    }
    catch (const std::exception&amp; e)
    {
        std::cout &lt;&lt; e.what() &lt;&lt; std::endl;

    }


}
</code></pre>
<pre><code class="lang-auto">
Severity Code Description Project File Line Suppression State
Error C2526 'PrepareFaceBank': C linkage function cannot return C++ class 'std::vector&lt;std::vector&lt;double,std::allocator&lt;double&gt;&gt;,std::allocator&lt;std::vector&lt;double,std::allocator&lt;double&gt;&gt;&gt;&gt;' detect-camera-demo D:\Project\Face\libfacedetection\example\Trian.cpp 67
</code></pre>