using c++ developed dll in .net

G

Guest

Hi All,

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.

Regards,
Y Iguchi
 
G

Guest

YIguchi said:
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.

DllImport exist to use Win32 DLL's in .NET programs.

Arne
 
B

Ben Voigt [C++ MVP]

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.
 
G

Guest

Ben said:
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.


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 ?

Arne
 
B

Ben Voigt [C++ MVP]

Arne Vajhøj said:
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.
 
G

Guest

Hi,

That is great .
I will be using crypto++ with that. I hope i will be use the same with c#.

Crypto++ compiles with /Mtd . I hope it will not cause any problem.

Are there any limitation in using the existing c++ Code with C# .net

Regards,
Y Iguchi
 
G

Guest

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.
2. Is this approach has some limitations too. i just wanted to ensure before
using this approach.

Regards.
Y Iguchi
 
B

Ben Voigt [C++ MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top