Please suggest me the best way to use .NET dll in VC++ project.
Is this the only approach or else there is another ?
Ashish Ashu
2009-11-26 10:46:13
I don't know any other practical approach.
Henrik
2009-11-26 10:51:00
+1
A:
If you make a Managed (CLR) VC++ project (I believe you can just set this in the compiler settings, though I'm not 100% sure if you need to change anything else in code to get it to work properly), you can use the .Net code without any "com" code, though you will have to write managed c++ code (this way you can also get the advantages of both managed .Net code as well as the advantages of standard c++)
Grant Peters
2009-11-26 10:59:08
Unfortunately it is not that simple. 1st you have to manage how all stuff will be communicating from managed to unmanaged area in your code (there are unmanaged pointers * and managed pointers ^ for example). Also C++/CLI doesn't support the whole C++ standard (specially in advanced areas like templates, etc).So if you really need a 'easy' way you should take COM. If you are ready for a 'hard' way (which will lead to very fast code) you can use C++/CLI
Oliver
2009-11-26 12:10:04
IMHO, handling the different C++/CLI pointers is a LOT easier than doing COM interfaces and I personally haven't had any problems using templates in C++/CLI, though you probably can't have managed templates, never tried that, but you can always fall back on generics if you need to (I'm not saying they are the same, but they both have advantages/disadvantages).
Grant Peters
2009-12-02 00:22:51