Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.mshtml.dll redistribution issues [closed]

I have made a C# BHO which is using Microsoft.mshtml.dll internally. Now to package this BHO do i need to also distribute Microsoft.mshtml.dll. Is it fine to add this dll with my dlls? Any legal issue ? This BHO works fine on dev environment as the Microsoft.mshtml.dll is present in visual studio (C:\Windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\Microsoft.mshtml.dll) guess, which will not the case on each machine. Please suggest.

like image 563
Jackie Avatar asked Sep 27 '13 13:09

Jackie


1 Answers

It is an interop assembly, it doesn't contain any code. Just declarations, auto-generated from the COM type library. Redistributing is thus fine. The only reason it is installed in the GAC at all is because it is a PIA, a primary interop assembly. You only need a PIA when you write a class library that exposes any of the interfaces in your own public methods. The client of such a library also needs a reference to the interop assembly to be able to use your methods and it must be the exact same one you use. This is rare in general, especially in a BHO.

If you use a Visual Studio version prior to VS2010 then just set the Copy Local property to True for the assembly reference. Rebuild and you'll get a copy of the DLL that you can deploy along with your own executables.

For VS2010 and up, you really want to favor the Embed Interop Type feature. Which embeds the interface declarations in your own assembly, only the ones you actually use. Which helps a great deal to keep the distributable size of your BHO smaller. And avoids the need to deploy that interop assembly. Strongly recommended.

like image 75
Hans Passant Avatar answered Sep 25 '22 14:09

Hans Passant