0

I have designed and implemented Algorithm in Vs c++ using OpenCv Library, now i need to check whether dll which i build is capable for integrating in c#.

  1. What are the things to consider when i'm building dll ( which is implemented in VS C++ using OpenCv Library )

  2. How to integrate dll in c# ( dll,which is implemented in VS C++ using OpenCv Library )

Pixel
  • 419
  • 4
  • 7
  • 17
  • What do you exactly mean with integrate? You mean you built an unmanaged dll (in C++) and you want to use it in a managed application (in C#)? If so you need to export the functions in the dlls and interop them in the C# application. [Example](http://www.dotnetperls.com/dllimport) – joell Apr 12 '13 at 11:39
  • @iVision what i meant is, i have an small algorithm in VS C++ ( used OpenCV library), now what are the things to consider while building a dll which supports C# easier – Pixel Apr 12 '13 at 11:51
  • One of the most important thing is the extern "c", it tells the C++ Compiler to not mangle the name, so you can interopt it in C#. [Whats the effect of Extern C](http://stackoverflow.com/questions/1041866/in-c-source-what-is-the-effect-of-extern-c) – joell Apr 12 '13 at 11:55
  • Yes What are the Basic Core OpenCv libs,dll's and headers required to run C++ dll [ used Opencv functions] in c# application?? – Pixel Apr 16 '13 at 12:02

1 Answers1

0

Any dll can be integrated in C#. However, if you want to make it easy for the implementer of the C# side, you can do some things:

Keep your interface clean C only. Primitive datatypes. Keep strings and structures to a minimum.

If that's not possible with your dll, consider writing a C++/CLI wrapper. That will make it a LOT easier to consume your dll.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • The biggest problem the author will have is the fact he is using OpenCV as this will require him to write a wrapper for any structures and datatypes that OpenCV uses in C#. – Security Hound Apr 12 '13 at 12:00
  • Uh... no? Only if he has those structures in his public interface. – nvoigt Apr 12 '13 at 12:18
  • nvoigt - Which is likely the case? – Security Hound Apr 12 '13 at 12:20
  • 1
    Maybe, but you made it sound like *using* OpenCV is a problem. It's not. Having *structures* (any kind, OpenCV or his own) in his interface will be a lot of work. – nvoigt Apr 12 '13 at 12:34
  • Its only a problem because he wants to PInvoke this library that he created. It only adds additional challenges. – Security Hound Apr 12 '13 at 13:37
  • What are the Basic Core OpenCv libs,dll's and headers required to run C++ dll [ used Opencv functions] in c# application?? – Pixel Apr 16 '13 at 12:03