#2: Yes, you could use VS to generate a wrapper around the COM type libs, but for type safety you should use an 'official' PIA from the company creating the COM object.
Suppose you create a .NET component that uses the object model of an Office application. Also suppose you have purchased/downloaded a component from another vendor. When your component references an assembly the specific public key, version number, assembly name, culture, etc must match exactly for that assembly to be loaded by your component. If you are to pass a type from your assembly to the assembly you purchased/downloaded the type, including key, version, etc must also match otherwise they are considered different types and the type cannot be passed to the other component.
For example, suppose you have a component that passes the Word Application object to another component. If you have two different PIAs for the Word application, then the type for one IA would be (for brevity, leaving out some information) Application#1 and the type of the other IA would be Application#2. These are different types, and you would not be able to pass them back and forth. Notice I said IA because when you generate a wrapper around a COM object, you are generating an interop assembly (IA), and not a primary interop assembly (PIA).
There are workarounds to this, such as publisher policy, but it is better to have the two components use the same assembly. There are reasons behind this, such as fixing 'DLL hell', type safety, etc. There is nothing wrong with generating an IA and using that, but you sacrifice any ability to pass a type in the IA to another application unless they also use your IA.
|