Project + Add link, select Microsoft.mshtml. If it does not appear in the list (this is the PIA), use the Browse tab and select c: \ windows \ system32 \ mshtml.tlb
Add a usage directive at the top of the source code file:
using mshtml;
Remember that you have deployment details. If the PIA is not installed on the target machine, which is unlikely, it is best to set the Copy Local property to reference the assembly to True. This creates the Microsoft.mshtml.dll file in the assembly folder. Copy it along with the EXE to the target machine. There are several cases where a PIA is required, not this one.
An update for this old post, .NET 4+ and VS2010 + now support the insert assembly interaction property of the link assembly. Also known as the No PIA feature. This obviates the need for PIAs and is the best way to work with interop assemblies. It is set to True automatically if your project is not running in the old version of VS.
It has no downstream sides, you no longer need to deploy the interop assembly, and the types of interaction you use are now embedded in your executable. Only the ones you use. Your code may need a little change, if you are now creating a COM object using new XxxxClass() , then you need to remove part of the class name.
Hans Passant Mar 07 2018-11-11T00: 00Z
source share