My understanding is that there are improvements in 2005 for IJW, which prompted the change in name. I haven't written managed C++ before now, and just used P/invoke for my C# code.
If you look at 4.1, that is the situation that I am in, for the most part. No flat API, so p/invoke is out for me. I've got an ANSI DLL and LIB with about 40 classes, of which I call many methods on 15 of them with parameters and returns of most of the others. I do have the source, but for many reasons (primarily that the rest of the group still uses VC6) I have to stick with the VC6 generated files. I've run into occasional compilation problems when header files include lots of implementation code (esp. that IMPORTs msxml4.dll or whatnot), but if I had enough time to research it i could get by that. As it is, I just made my own header that has no implementation details -- not the best solution, but it works. I also have to do my own string marshalling which is a pain. But once compilation problems are solved, linking hasn't been a problem. I suspect, as someone mentioned above, that the pascal convention is your problem. On 7/20/06, Eddie Lascu <[EMAIL PROTECTED]> wrote:
Thank you, Roy. I have purchased the electronic version from Apress web site (got it cheaper too) and got reading within 5 minutes. You gotta love the Internet age. Actually Chapter 4 is dedicated to C++ Interop which is the new name for IJW (It-Just-Works). Reading I saw that IJW is good only if your Managed code is C++ and only if you have the source for the unmanaged code. Since I only have a dll, an accompanying lib and some header files, I wasn't sure IJW will work (any comments here?), so I switched back to P/Invoke and eventually I got it working. Well, at least the first call into the API library returned successfully and created the object I needed. One observation: - some of the methods in the native library return pointer to objects, but the interface specifies them as (void *). When I tried C# and declared the return type as object I got some marshalling exceptions (P/Invoke not supporting variant return types). Once I switched to C++ and declared the return type as (void *) everything worked fine. How would you deal with that? Anyway, thanks for your suggestion. This book sure looks like an important resource for anyone having to deal with interop issues. Cheers, Eddie -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Roy Green Sent: Wednesday, July 19, 2006 6:51 PM To: [email protected] Subject: Re: [ADVANCED-DOTNET] Linking an unmanaged C++ .dll in a VS.NET 2005 Managed C++ Class Library Hi, I've had to link to a lot of VC6 libraries lately, and the following book has been extremely useful: http://www.apress.com/book/bookDisplay.html?bID=10116 Chapter 4 is what you want. On 7/19/06, Eddie Lascu <[EMAIL PROTECTED]> wrote: > Hello Experts, > > I have this third party .dll that was developed in Visual C++ 6.0. I have > the ".lib" file and also some header files to include in my project. I am > trying to wrap it into a Managed C++ Class Library developed in Visual > Studio.NET 2005. I picked Managed C++ because I read the interoperation is > easier from C++ than C# or VB.NET. > Anyway, I am getting linkage errors for virtually every call into the > library (LNK2028 paired with LNK2019). I have linked the ".lib" file and > made sure the ".dll" file is found in the local folder, but I still get > these linkage errors. > This library is quite old and I had to make some changes in the header files > to make them compile. I read about the myriad of compilation/linkage > directives and I am at loss with them. > > Are there any web recourses to guide me through all the steps that need to > be followed to get this to compile and link? > Any suggestion will be appreciated, > Eddie > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
=================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
