An error solution for deploying mshtml assembly in Winform

Source: Internet
Author: User

When deploying a Winform application in the vs2008 environment, Microsoft mshtml. dll assembly is used because an Html editor is referenced,

The version is 7.0.3300.0.

E: \ Vs2008 installation directory \ Visual Studio Tools for Office \ PIA \ Office11 \ Microsoft. mshtml. dll

E: \ Vs2008 installation directory \ Visual Studio Tools for Office \ PIA \ Office12 \ Microsoft. mshtml. dll

When adding a project reference, you can select it in the GAC Assembly, because the component has been registered and deployed to GAC When Visual Studio Tools for Office is installed.

The program runs on the local machine without errors.

Deploy to the client. Note: the client does not have the vs200X development environment ., An error occurred while running the result. The prompt is:

System. Reflection. TargetInvocationException: An exception occurred to the calling target. ---> System. IO. FileNotFoundException: failed to Load file or assembly "Microsoft. mshtml, Version = 7.0.3300.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a" or a dependent item. The system cannot find the specified file.

The default reference attribute is changed:

Copy local = True

Specific version = false;

The problem persists. An error occurred while directly copying the dll to the client.

Later, I saw an article about re-generating a version of mshtml. dll, which can be deployed.

Http://www.cnblogs.com/gjs85/archive/2010/01/23/1654761.html

The general idea is:

Because Microsoft. mshtmal. dll. This dll is from the mshtml In the system32 folder. tlb (COM-type library file), so we only need to use the TlbImp.exe COM-Type Library export tool that comes with VS2008 to export this tlb file again. I use the following script to export: tlbimp mshtml. tlb/out: mshtml. dll

Finally, an mshtml is obtained. dll Assembly file. mshtmal. replace dll with mshtml. dll, and then the dll can be added to the installation project.

I tried it and failed. I thought about it later. This is not necessary because the local machine can run and the dll is available, but the Assembly cannot be identified when it is deployed to the client.

 

So when I added a new reference, I observed the reference interface and found three mshtml instead of two.

So try to add the third,

 

 

Change the default reference property:

Copy local = True

Specific version = false;

 

Add the main program \ bin \ Microsoft. mshtml. dll to the installation and deployment Program, and copy it to the bin during compilation.

Deploy to the client. OK!
This file is relatively large, with a size of 7.63 MB and a size of 1.7 MB after the installation and deployment Program is compressed. Therefore, there is also a lightweight alternative solution, with only over 100 K,

See,

Http://www.cnblogs.com/wuhuacong/archive/2009/11/12/1601532.html

Http://www.codeproject.com/KB/miscctrl/csEXWB.aspx? Msg = 2814607 # xx2814607xx
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.