views:

126

answers:

6

I've been working as .NET developer for a few years now and have no other windows development experience worth noting. Now I'm in a position where I have to use and maintain .NET code that uses older VB6 code. Other people are maintaining and replacing this code but for the next couple years I'll have to live with it. As far as I can tell, based on my very limited knowledge, they currently register the dlls with regsvr32 and then add references to the .net projects that use them. The act of adding the reference is creating the interop dlls. I know they frequently have problems. One of the more common one is that they have to remove the references, re-register, and re-add the references. None of the more experienced developers seem to know what is going on. They all seem content with this but it can burn half a day of work. Since I know next to nothing about COM I thought it would be best if I did some reading to try and learn how things should work.

Does anyone know of any good books that can help me learn about COM from the point of view of someone who is consuming them but not creating them?


EDIT:

Thanks for all of the input!

As of this edit the recommendations are:

  • .NET and COM: The complete Interoperability Guide. x2
  • Essential COM x2
  • Advanced Visual Basic 6 x1
  • Professional Visual Basic Interoperability - COM and VB6 to .NET x1
  • COM+: Base Services x1

The VB books seem interesting since it looks like some of the issues here may be specific to VB6. Also, it sounds like Essential COM may be good when I am really ready to dive into COM but it appears to be lacking the .NET side of the show.

That said it looks like .NET and COM: The complete Interoperability Guide will be best for helping me transition from the .NET world. It helps that I was looking at this one before I posted and it tied for first in terms of number of recommendations.

I'll make my final decision in the next couple of days but I'm leaning towards .NET and COM: The complete Interoperability Guide for now and maybe following it up with Essential COM. I may also throw in "Professional Visual Basic Interoperability - COM and VB6 to .NET" since it is so cheap.

Also, Thanks to Hans Passant and Paul Farry for their input on the specific issues. Once I've done some reading and understand more about how our current setup works I may open a new question for this and link to it from here.

+2  A: 

An old but really good book on the topic is .NET and COM: The complete Interoperability Guide by Adam Nathan.

Chris Taylor
+2  A: 

I used NET and COM: The Complete Interoperability Guide by Adam Nathan way back and remember that it was quite helpful.

However, if you'd want to really know how COM works you should look at Essential COM by Don Box, though probably only if you know C++.

ho1
My c++ hasn't been used in years so "Essential COM" might be a bit rough for now but I will add it to my maybe later list.
drs9222
+5  A: 

This is pretty specific behavior for VB6, I doubt you are going to find it in a book. The issue is that VB6 will generate new GUIDs for the IIDs and CLSIDs of the coclasses and interfaces if you rebuild the DLL. You avoid it by using the "binary compatibility" option in the VB6 project settings. I forget where exactly it is located, it has been too long.

With new GUIDs, the existing interop library is junk and has to be re-generated. Which is indeed what happens when you remove the COM server reference and add it back.

Btw: the developers ought to take a look at their registry. It must be filled with garbage from all these COM servers that no longer exist. HKCR\CLSID key.

Hans Passant
Interesting, I'll have to look at this more. However, I have checked and they do have the "binary compatibility' flag set already.
drs9222
@drs: one failure mode is not updating the copy. New interfaces that are not present in the copy will get an arbitrary GUID that will keep changing. Use OleView.exe, File + View Typelib to check.
Hans Passant
+1  A: 

A very good book about COM and VB6 is Advanced Visual Basic 6. It covers the nuts and bolts of how VB6 works with COM, and why it works that way, icluding the binary compatibility issue @Hans has already alluded to. You can check out the author's website at http://www.powervb.com/

Garett
I'll keep this in mind although I think this more VB than I want and less COM/.NET interop than I need.
drs9222
+1  A: 

Another option is Professional Visual Basic Interoperability - COM and VB6 to .NET

Rob Windsor
While the title sounds promising, the "From the Publisher" section says "This book is aimed at experienced Visual Basic developers who need to make COM and VB6 code interoperate with the new .NET platform." I am not an xperienced Visual Basic developer. However, since it is only $3.75 new, I might get it anyway.
drs9222
+1  A: 

Hi

IMHO, if you are going to maintain COM code it makes sense to learn as much as you can about it. Also, IMHO, Essential COM is one of the best books about COM. Another book that I think worths reading is Inside COM+: Base Services.

Hope this helps.

Vagaus