Has anyone managed to get zlib 1.2.3 to work within a managed MS Visual C++ 2005 Express project (using /clr:safe) I have gone so far as to successfully rebuild the zlib DLL and lib within the same IDE (different project) successfully using the original sources (though the project had to be converted automatically from the older version first). However, zlib is not in C++ .Net (it's pretty much standard C++) and so I cannot simply reference its DLL as part of the project (it's not clear to me how you'd make that call). I'm in need of some direction, i.e., how to load the DLL and how to reference some part of it. I'm getting nowhere fast so any help is appreciated. I figure it has to do with DllImport but I'm not sure how to use it properly yet.
[Time passed... coding happened...]
I did get this much to work finally:
[DllImport("zlib1.dll", EntryPoint="zlibVersion", SetLastError=true)]
String ^ zlibVersion(); // returns "1.2.3" when invoked from "main" which is as expected
Now that I think I can deal with functions, I wonder how to get all the external variables to be visible (i.e., #defined constants)... if nothing else I can just use the original header file (with adjustments) but perhaps there is a smoother way
Thanks in advance,
Marty

Using zlib within a managed MS Visual C++ 2005 Express project
shivali.sadavarte
Jamie Thomson
KrisFB_APPS
error C3115: 'System::Runtime::InteropServices::DllImportAttribute': this attribute is not allowed on '<any given argument typedefed in zlib.h>'
Below is a snippet from the start of my code. Rearranging the includes doesn't seem to help matters a great deal, though if zlib.h is above DllImport I get unresolved external token/symbol errors during compilation.
......
#include "stdafx.h"
using namespace ThisApp;
using namespace System::Runtime::InteropServices;
#pragma warning(disable : 4956 4959)
#include "zconf.h"
[DllImport("zlib1.dll", SetLastError=true)]
#include "zlib.h"
#pragma warning(default : )
[STAThreadAttribute]
int main(array<System::String ^> ^args)
......
I am getting close to giving up on this and using something else (or even worse, rewriting zlib) but it seems to me this shouldn't be that difficult.
Regards,
Marty
Pockey
Of course, the vast majority of things with IJW will never work with /clr:safe. Even though you can disable most compiler errors re verifiability you won't get a verifiable image. That said, that's hardly different from the PInvoke case.
-hg