Reputation: 659
I have a project where I must make use of an API to read file of a proprietary filetype. It is closed source, just a bunch of DLLs that can be added as a reference in my project (currently I am using C#). However, I also wish to make use of a C++ library, OpenMS (http://open-ms.sourceforge.net/) in order to manage and analyse the data I obtain. I have read a bit about P/Invoke and creating a wrapper (and some others suggested other methods such as this: http://www.codeguru.com/cpp/cpp/cpp_managed/interop/article.php/c6867 ) but I am not sure how I should go about this and what the best way would be, especially as most examples I have seen are very simple and this library has many complex data types etc. Is it possible to automate the process of creating a wrapper as the library is very large?
Upvotes: 1
Views: 292
Reputation: 63298
Mono guys in fact develop something different from P/Invoke or C++/CLR and may be more friendly to C# developers,
http://tirania.org/blog/archive/2011/Dec-19.html
The question is how mature it is right now, but you can play with it and learn,
Upvotes: 1
Reputation: 244991
You don't add unmanaged DLLs as references; that only works for managed DLLs written in a .NET language.
If you're using C#, P/Invoke is your only option. Yes, the difficulty and time consumed by doing so will increase proportionately with the complexity of the library. You will need to ensure that there are managed equivalents of all the data types used by the library, defining them yourself explicitly if necessary. Unfortunately, I am not aware of any way to automating this process.
If switching to C++/CLI is an option, you will have a much easier time as you can consume the unmanaged library directly, mixing it with your .NET code.
Upvotes: 1