Note that there are some explanatory texts on larger screens.

plurals
  1. POC# code can't "see" the methods in my C++ dll
    primarykey
    data
    text
    <p>I have a code written in C++ (that I did not write) and want to use it in C#, so I decided to make a dll and use this class from there.</p> <p>I have very little knowledge of C++ and am having problems referencing the methods of this class in my C# project.</p> <p>The C++ code is like this:</p> <pre><code>#ifndef BeamAn_class #define BeamAn_class #define DllExport __declspec( dllexport ) #include &lt;vector&gt; #include &lt;cmath&gt; using namespace std; public class DllExport BeamAn { public: BeamAn(); ~BeamAn(); bool SetGeometry(vector&lt;double&gt;); //I didn't put the DllExport here because I already did it for the whole class. It's okay to do this, right? //other public methods an stuff private: //private methods an stuff } #endif </code></pre> <p>In my C# project I added the reference to the C++ dll normally (right click on the project, add reference. The .lib and .h files are in the same folder of the dll).</p> <p>But looks like Visual Studio can't "see" the methods of my class. I can create a object of the BeamAn type, but can't use any of its methods. For example, I can do this: BeamAn contBeam = new BeamAn(); But can't use any of the methods or atributes inside the class, like this: contBeam.SetLoadFactors(1.0,1.2); </p> <p>Visual Studio says that "BeamAn does not contain a definition for 'SetLoadFactors' and no extension method 'SetLoadFactors' accepting a first argument type 'BeamAn' could be found (are you missing a using directive or an assembly reference?)</p> <p>Is there more something I should write in the C++ code to make the dll work properly, or am I doing something wrong when referencing it? I know that I'd have to use "DllImport" in my C# code if I was explicit linking, but that's not what I want to do.</p> <p>Thank you very much!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload