How to add a reference to mshtml version 9 in .NET

十年热恋 提交于 2019-12-01 04:29:19

These are the hazards of COM versioning, aka DLL Hell. The PIA you have installed in the GAC is the lowest common denominator, it makes your code work with any version of IE 6 and later. Your approach is otherwise sound. The warnings are real, you can't use the flagged members from a scripting language or any other client that relies on COM automation. You stay out of trouble by simply not using them, not difficult.

You got the error when you added the reference because you used the wrong version of Tlbimp.exe. Probably the .NET 4 version, judging from the error message. The 3.5 compatible version is located in c:\program files\microsoft sdks\windows\v6.0a\bin. Otherwise the one you'll get when you use the VS2008 Command Prompt. Verify by typing where tlbimp.exe at the command prompt.

Some odds that you'll get the PIA loaded instead of your custom interop assembly. Not sure, you can tell from Fuslogvw.exe, configured to log all bindings. Your /asmversion should avoid it. Best to create a completely bogus version number so it can never match a PIA version, like 1.0.0.0

And, of course, your program won't work on the user's machine when it doesn't have IE9 installed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!