One of the ways of mixing 'C' and .NET languages, such as C#, is by 'wrapping' the C library in a bit of 'managed C++'.
Since C# thinks in an OO (Object Oriented) way, you'll have to give it classes the way it want them. The most basic way of doing this would be to provide the OpenSSL API in a single class (often referred to as a 'Facade'; see also Design Patterns by Gamma et al, if you don't know that sort of stuff already). Where OpenSSL requires or provides data structures, such can be equally wrapped in (C++ --> .NET) classes. Or you can sit down and think about what you need to use from OpenSSL and ponder /how/ you wish to interact with it, then write the (probably more complex) interaction in [managed] C++ entirely to keep your .NET interface strictly on-purpose and extremely lean. This will shift part of the implementation into the C++ realm. One of several design decisions you need to make here. Technical Stuff: to get an idea how it /could/ be done, you can have a look at something similar which I did for the htmltidy library: have a look at the code for 'HTMLTIDYwrapper for .NET' which is a generic, rather thin, yet very wide, interface for .NET code to htmltidy. It's available here: http://hebbut.net/Public.Offerings/index.html it's MSVC2005-based, but will very probably also compile on MSVC2008. There's also a chunk of MSVC2003 code in there, but that is rather old and unsupported and may not compile anymore; managed C++ has changed quite a bit in its phrasings from 2003 to 2005. The example I mentioned is for 'generic purposes', and some of it's code is still under heavy development, but you'll quickly recognize those bits and pieces, I'm sure. At least, it's a working example, still in use in production software. Use as you see fit. All in all, rather simple (with a few technical caveats though), and not a single day's work, mind you. Of course, it depends on how much OpenSSL you wish to provide to .NET here. Haven't checked if someone already did a 'generic one' already, though. The mono folks /might/ just have an answer there, so it might be worth to get a second opinion there. Take care, Ger 2008/7/14 魏露 <[EMAIL PROTECTED]>: > Hello, > > OpenSSL has wrote by the C language, so she cannot be used in the > Microsoft .Net Environment directly. I use OpenSSL for create different > kinds of certificate with openssl.exe now. But I think it's very annoying > for our customers. So I make my WindowsForms Application interacted with > Console Application openssl.exe. But I found it is not a good idea. It cause > many problem and hard to do. I hope I can integrated OpenSSL with my .Net > WindowsForms Application in program way. So is there someone could give me > some advice? > > > > Thanks -- Met vriendelijke groeten / Best regards, Ger Hobbelt -------------------------------------------------- web: http://www.hobbelt.com/ http://www.hebbut.net/ mail: [EMAIL PROTECTED] mobile: +31-6-11 120 978 --------------------------------------------------
