Does anyone know how to reference a COM library from the command-line? Specifically, I need to reference CDOSYS.dll. Whenever I try to include the reference when I compile I get a message saying:

fatal error CS0009: Metadata file 'c:\WINDOWS\system32\cdosys.dll' could not be
opened -- 'An attempt was made to load a program with an incorrect
format. '

Anyone know how to do this?

NOTE: I have to do this in command-line. Adding the reference with an IDE isn't an option. I know how to do that.

10 Years
Discussion Span
Last Post by bondo

You can't link directly to a COM library; you have to link to a .NET interop library. The VS IDE secretly generates this library for you when you add a COM project reference. Since you're using the command line, you'll have to generate it yourself. Use tlbimp.exe; it comes with the SDK.

Votes + Comments
Exactly what I needed
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.