> a) Modify the ZLib source so that it compiles as C++ code.
>
> b) Separate the ZLib code into an independent DLL that the mixed-mode
> wrapper calls.
>
> c) Just keep using the .NET 1.1 version of the DLL.

Signature
Kind regards,
Bruno van Dooren
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"
> b) introduces extra work. If you are going to do work anyway, you might as
> well go for solution
ZLib already comes as an unmanaged DLL, though. Sometimes I use the DLL
version, and sometimes I link it to the project statically. But it takes
0 time to create that DLL -- it already exists.
I would not modify the ZLib code (other than trivial-to-fix conflicts in
the header file). It's a very stable, open source library. Once I
thought of rewriting it in C++, but it would be a tremendous amount of
work, I would lose connectivity with the original library, I would lose
stability and access to the security patches. So instead, I just wrapped
it into a C++ class, instead of rewriting it.
So my recommendation is to download the DLL version of ZLib, and try to
call it from a mixed-mode project. I have many unmanaged DLLs that I'm
using from mixed-mode code, and ZLib is one of them.
Although I haven't used ZLib directly from C++/CLI, I'm using an
unmanaged DLL of mine that uses the ZLib DLL internally, and I have
absolutely no problem using this from C++/CLI:
[C++/CLI mixed-mode app] ---> [unmanaged DLL] ---> [original ZLib DLL]
Tom
DFB - 14 Jul 2006 20:19 GMT
> So my recommendation is to download the DLL version of ZLib, and try to
> call it from a mixed-mode project. I have many unmanaged DLLs that I'm
> using from mixed-mode code, and ZLib is one of them.
Yes, I assumed that this would be the simplest way to go since it should not
be any problem to call the ZLib DLL from the mixed-mode DLL. Deployment
requires two DLLs, though.
I wonder, however, if the limitation on C code in CLR mixed-mode DLLs could
be worked around by statically linking to a library containing the ZLib
source, rather than compiling the C directly into the DLL. I haven't tried
this yet.
Any insight about this technique?
Thanks,
-Dave
Tamas Demjen - 14 Jul 2006 20:52 GMT
> I wonder, however, if the limitation on C code in CLR mixed-mode DLLs could
> be worked around by statically linking to a library containing the ZLib
> source, rather than compiling the C directly into the DLL. I haven't tried
> this yet.
I haven't tried that, but that should work too. I think it's worth a
try. Just be sure to switch the compiler to unmanaged mode for the
entire zlib header file:
// mixed-mode project including zlib.h:
#pragma unmanaged
#include "zlib.h"
#pragma managed
Also use VC++ 2005 to produce the zlib.lib file, not another compiler.
Other than the /clr option, the rest of the compiler options should
match (same data alignment, use multi-threaded dynamic RTL, and so on).
Tom
Bruno van Dooren - 14 Jul 2006 21:36 GMT
>> b) introduces extra work. If you are going to do work anyway, you might
>> as well go for solution
>
> ZLib already comes as an unmanaged DLL, though. Sometimes I use the DLL
> version, and sometimes I link it to the project statically. But it takes 0
> time to create that DLL -- it already exists.
Ah. Not knowing ZLib, I didn't know that.
In that case, option B could have been described better as 'use the existing
ZLib dll in a mixed mode .NET wrapper'.
With that in mind, your suggestion is better.

Signature
Kind regards,
Bruno van Dooren
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"