How to deploy mshtml assembly error in winform (this application requires that the Assembly miscrosft. mshtml be installed in the Global Assembly Cache GAC)

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 an mshtml. dll version, which can be deployed.

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

The 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.

When you re-Add a new reference, observe the reference interface and find 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.