YIguchi said:
Hi Ben,
I will be using crypto++ with the c#. I just wanted to confirm one thing
1. Does this method works with /Mtd too.
No, I think /MD or /MDd is required for C++/CLI to create a .NET assembly.
I doubt that will break crypto++.
2. Is this approach has some limitations too. i just wanted to ensure
before
using this approach.
The only limitation is that the code you write using the C++/CLI syntax is
only usable in a .NET program, so your customers need .NET installed. And
of course not just .NET Framework, but also the updated VC++ runtime
(vcredist_x86).
Native C++ classes can be used in a .NET program via C++/CLI (not directly
from C# or VB) or from native code. This feature is called "C++ interop" or
"It Just Works" and is much better than p/invoke for working with native C++
code or any library with C headers.
Regards.
Y Iguchi
Ben Voigt said:
Arne Vajhøj said:
Ben Voigt [C++ MVP] wrote:
YIguchi wrote:
i wanted to know how can i use c++ developed in my c# code.
I want to use crypto++ library in my c# code. Any pointer would be
helpful.
Use C++/CLI to call crypto++. Make a library wrapping just the crypto
functionality you need, make it into a "ref class", and add it as a
project reference from your C# project, and you'll be able to use it
just
like the Microsoft classes.
DllImport exist to use Win32 DLL's in .NET programs.
And you need a C API to do so, not C++. When C++ is exposed as
COM/ActiveX, then .NET supports the API that way. But I don't think
crypto++ is.
Why write a C++ wrapper instead of simply calling the code
you want to call ?
I meant to suggest that the wrapper should be at a higher level of
abstraction, providing application-relevant functions. But I can
definitely
see why you interpreted my suggestion as a thin one-to-one forwarder.