Tuesday, December 23, 2003 - Posts

ComInterop by Hand

Has anyone had the pleasure of having of doing COM Interop by hand? If so, what are your pros and cons of doing it this way?

We're currently working on a project that depends on a COM component. The client stated that we could not simply wrap this component using the .NET tool. They stated the reason why is because translation doesn’t occur properly, meaning – it don’t work J. So they wanted all Interop code to be hand coded, which I can't claim I've ever done before for a real project.

So I took it upon myself to do this part of the project. Not knowing much I found the process quite perplexing and not well documented, but after a while I finally wrapped my head around it and it’s really quite easy (but weird), thanks to the COM/OLE Viewer (yes a VS 6.0 tool). I’ll get into this tool is an absolute must in an article I’m going to write about custom COM Interop, but for now I’ll tell you that the tool provides you with the appropriate signatures you need to create for you interfaces and classes. If anyone knows a “.NET tool” for this please let me know. Anyway, after finally figuring out how to do this stuff the rest was easy, cumbersome – but easy. It takes a long time to do this crap.

So enough background, the real reason for this post is to give you some pro’s about doing COM Interop by hand despite my bitching.

1.)    You control how much actually is wrapped: By creating your own wrapper you don’t have to wrap the entire COM component. In this particular project the “Interop.SumCOMComponent.dll” created was over 1MB. That is huge for distribution; it was actually larger than the entire project. By creating Interop for just the functionality we needed we cut the size to under 100K.

2.)    You don’t have to create an additional layer of abstraction: When using the .NET tool you create a complete wrapper and traditionally I would create another class within the project for all my business rules that will then invoke methods of the Interop assembly. By creating your own Interop you don’t have to do that. You put it all into one.

I could really break both of these points into many, many other “best practices” points – but I’ll let you derive those. After the project is finished I’m going to write an article on doing this, using the same well known COM component this project used to illustrate both the pros and cons of using .NET’s built in Interop capabilities.   

 

JunkieHood Downtime

Hello All,

Some of you may have experienced a brief downtime this evening of junkiehood (dnj and sqlj) - we added a new server to our farm and needed to do a full reboot (I really need to get my MCSE to figure all this server setup crap). But we're up again, well almost. One of our servers hasn't started yet, but the great people at http://www.securewebs.com are working on it right now. They actually emailed me within 1 minute after I initiated a full restart of our farm to see if everything was ok, now that's service. They really are the best company i've ever hosted with! Scott, Emil and everyone else there are so great!

Happy Holidays all!