Today, I saw a code to identify codes, which referred to the Mshtml.dll, looking for a half-day originally is Microsoft.mshtml.dll. Check this DLL when also found a few questions about this DLL add the article. By the way, the original DLL has three, to add a reference to pay attention to.
First post:
1. Adding references to the issue
Microsoft.mshtml.dll files are typically stored in three places under the development environment. So when you add a reference, there are three seemingly identical items. For developers, referencing any of them does not affect normal development. But the problem will be after the software release! When running on a client's machine, it is often suggested that the file's signature is incorrect and cannot be loaded.
The workaround is to remove the current reference to the MSHTML. Re-select the correct reference. is to choose the bottom one. The path is: X:\Program files\microsoft.net\primary Interop Assemblies\microsoft.mshtml.dll. Pull the Reference dialog box large to see the path to the file.
2. Type selection Error
If the problem is solved, or the first choice is right. It is possible for the client to run and report that System._comobject cannot cast to Htmlwindow2class, Htmldocumentclass, or other similar errors. Run on the developer's machine, but it's perfectly normal. At this time usually we will be crazy to catch, completely do not know what is the reason! The Obj.tostring () display in the development environment is htmlxxxxclass the result on the client is System._ ComObject. The workaround is simple to replace the htmlxxxxclass with htmlxxxx.
The second article:
The Microsoft Mshtml.dll assembly is also used, but after the user's computer is installed, the exception is:
System.Reflection.TargetInvocationException: The target of the call has an exception. ---> System.IO.FileNotFoundException: Failed to load file or assembly "microsoft.mshtml, version=7.0.3300.0, Culture=neutral, PUBLICKEYTOKEN=B03F5F7F11D50A3A "or one of its dependencies. The system cannot find the file specified.
Workaround, select the highlighted DLL to do it.
Attribute selection:
Copy Local =true
Specific version =false;
The reasons are:
Because Microsoft.mshtmal.dll this DLL is exported from the Mshtml.tlb (COM type library file) under the System32 folder, we only need to use VS2008 's own TlbImp.exe COM type library export tool to The TLB file will be re-directed again.