Creating a C++ library for use in C# project
-
Hello, I am trying to create a dll using c++ that I can then use and call functions out of in C#. I have a general idea of what to do, but I don't know the specifics. I am using visual studio 2005. What type of project should I create in c++? Does anyone know of any source code out there that might have some simple exambles? Once I have created my dll, I add it to C# as a reference. But after that what do I do?
-
Hello, I am trying to create a dll using c++ that I can then use and call functions out of in C#. I have a general idea of what to do, but I don't know the specifics. I am using visual studio 2005. What type of project should I create in c++? Does anyone know of any source code out there that might have some simple exambles? Once I have created my dll, I add it to C# as a reference. But after that what do I do?
You would use Platform Invoke to call from C# into the DLL. Read the help for Platform Invoke.
“Cannot find REALITY.SYS...Universe Halted.” ~ God on phone with Microsoft Customer Support
-
Hello, I am trying to create a dll using c++ that I can then use and call functions out of in C#. I have a general idea of what to do, but I don't know the specifics. I am using visual studio 2005. What type of project should I create in c++? Does anyone know of any source code out there that might have some simple exambles? Once I have created my dll, I add it to C# as a reference. But after that what do I do?
Depends, if your using the .Net framework for the c++ DLL then you use it like any other class. If you're not using the .Net framework for the c++ dll then you will have to use P/Invoke As for the type of project to make, I think you just need to make a Class Library.
My current favourite word is: Nipple!
-SK Genius
-
Hello, I am trying to create a dll using c++ that I can then use and call functions out of in C#. I have a general idea of what to do, but I don't know the specifics. I am using visual studio 2005. What type of project should I create in c++? Does anyone know of any source code out there that might have some simple exambles? Once I have created my dll, I add it to C# as a reference. But after that what do I do?
Is there any specific reason why you need the dll in C++? If your C++ dll is on .NET framework, you can directly add reference to your c# project. Alternatively, you can use C++/CLI other than C#. So you can use the C++ classes by just importing the necessary headers.
Navaneeth How to use google | Ask smart questions