COM Interop in .Net
I had to make COM Interop with .Net and VB6 work a few months back. Since I'll probably have to do that again soon, I figured a post on this was timely.
Getting everything to work correctly wasn't as easy as advertised. True, I did some Google searches for useful information. I did get the whole thing to work, complete with IntelliSense working from VB6. It was great.
A couple of months after that, I stumbled across this
article that talks about all the stuff they don't tell you (that I had to figure out). I took a quick read of it and I think it covered all the stuff I had to figure out. I was going to write down the real steps, but why bother, I think they're all here!
Besides that article, there are a couple of other related articles I ran into that were useful. I might as well list those, too:
9/8/2005: I stumbled across another useful attribute today: ComClassAttribute. The main article referenced above doesn't reference this attribute. It's in the Microsoft.VisualBasic namespace (why not just put it with everything else)?
Missing friend keyword in C#
While I like C#, there are some things missing when I compare it with the C++ world. Today's missing feature is the
friend keyword. It would elegantly solve my current problem. Without it, I'm going to end up with a public contsructor for something that really shouldn't have it.
internal won't work because this class needs to be in a separate assembly.
I add that to some other things I wish I really had in C#
- Multiple inheritance
- const keyword
- Believe it or not, I like the explicit nature of pointers. It's strange getting used to what's really happening in memory and figuring out what methods are doing and "trusting" the language to do what you want. A couple times I've been burned.
- There was something else...and I forget what it was right now...