On Friday, I was assisting one of our client’s developers in building and deploying their first COM interop application.  It has been a while (early 2002 to be exact) since I’ve done any COM interop.  So, needless to say, I had to catch up rather quickly.

The application we are deploying is launched from a legacy VB6 application that launches other VB6 applications.  The .NET application connects to DB2 running on an AS400 through OLEDB.  After of a couple of hours of trial and error, we got the application up and running.  So, I’m giving you, my three readers, a list of things to remember when doing COM interop to simplify development and deployment.

Things To Remember During Development

  • Create your own interface to expose to COM
  • Provide a Guid, interface type and Dispatch IDs using the attributes under the System.Runtime.InteropServices for your interface
  • On the class that implements your interface, provide a Guid and Prog ID using attributes
  • Using the ClassInterface attribute, specificy the ClassInterfaceType.None option.  This will prevent the creation of an interface for COM
  • Use the automatic COM registration setting under your .NET project to facilitate registration

Things To Remember During Deployment

  • If you application uses a configuration file, remember to name it after the non-.NET process that’s calling6. your component.  For example, if your legacy application is called myVB.exe, your configuration file is called myVB.exe.config
  • Place the configuration file in the same directory as your executable
  • Remember to use the /codebase option for RegAsm.exe to specify the calling path of your COM module.  If omitted, you must place your assembly in the same folder as your executable

I hope this information is helpful to those doing interaction with legacy applications through COM.  If I come up with more information, I will post it.

Keep on codin’!