RAD Studio for Microsoft .NET - Embarcadero Technologies
RAD Studio for Microsoft .NET - Embarcadero Technologies
RAD Studio for Microsoft .NET - Embarcadero Technologies
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
1.2 Developing Applications with <strong>RAD</strong> <strong>Studio</strong> <strong>for</strong> <strong>Microsoft</strong> .<strong>NET</strong> Deploying COM Interop Applications<br />
1.2.2 Using DrInterop<br />
The drinterop command line tool examines an assembly and produces a set of diagnostic messages that help you prepare<br />
the assembly <strong>for</strong> use with COM/Interop.<br />
The drinterop tool is located in the bin directory of the product installation. It is invoked by typing<br />
drinterop assembly<br />
Message Cause<br />
Assembly ComVisible attribute is true when it<br />
should be false.<br />
Assembly, class, or interface is exposed to COM but<br />
does not contain the Guid attribute.<br />
A type library should be generated and registered <strong>for</strong><br />
assembly.<br />
Assembly does not contain the TypeLibVersion<br />
attribute.<br />
Reduce registry size by adding attribute<br />
[ClassInterface(ClassInterfaceType.None)]<br />
to class.<br />
Note: The drinterop<br />
tool will not print any messages if it does not find any of the above conditions.<br />
1.2.3 Deploying COM Interop Applications<br />
The [assembly:ComVisible(bool)] attribute is set to true, or<br />
is not present.<br />
Assemblies should be hidden from COM to reduce registry clutter.<br />
Set the ComVisible attribute to false, and selectively expose<br />
classes and interfaces.<br />
The assembly, class, or interface has the ComVisible attribute set<br />
to true but does not contain a Guid attribute.<br />
This message is generated when a type library is not found in the<br />
same directory as the assembly.<br />
The assembly does not contain the [assembly:<br />
TypeLibVersion(x,y)] attribute.<br />
By default type library version numbers are generated using only the<br />
first two numbers of the assembly version. Using the TypeLibVersion<br />
attribute can help avoid problems where two assemblies would<br />
produce the same type library because the first two digits of their<br />
version number are the same.<br />
The class does not contain the ClassInterface attribute.<br />
By default, each class will cause the creation of a corresponding<br />
interface with the class name prefixed with an underscore character.<br />
This interface has no methods associated with it.<br />
You can reduce registry size and clutter by putting the<br />
[ClassInterface(ClassInterfaceType.None)] attribute on<br />
the class.<br />
Two things are important to keep in mind when working with unmanaged components. First, remember that an interop assembly<br />
is not a replacement <strong>for</strong> the COM server; it is a stand-in, or proxy <strong>for</strong> it. The interop assemblies produced by tlbimp and <strong>RAD</strong><br />
<strong>Studio</strong> are not trans<strong>for</strong>mations of the component's unmanaged code into managed code. Every file required by the component in<br />
an unmanaged deployment environment, must also be deployed in a managed environment in addition to the interop<br />
assemblies. Second, the .<strong>NET</strong> Framework's interop services do not circumvent the requirement of registering the COM server on<br />
43<br />
1