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

I want to use some of the new features of mshtml.dll version 9.0 such as IHTMLCSSRule.

The interop version in the following folder is version 7.0.3300.1:

C:Program FilesMicrosoft.NETPrimary Interop AssembliesMicrosoft.mshtml.dll

The COM version in the following folder is version 9.0.8112.16441:

C:WindowsSystem32mshtml.dll

From what I could ascertain from the web, I should do this to create a .NET interop version 9:

d:zTemp>tlbimp mshtml.tlb /out:Microsoft.mshtml.dll /namespace:mshtml /asmversi on:9.0

This seems to have worked but generated the following warnings:

TlbImp : warning TI3001 : Primary interop assembly 'Microsoft.mshtml, Version=7. 0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is already registere d for type library 'C:Windowssystem32mshtml.tlb'. TlbImp

: warning TI3016 : The type library importer could not convert the signature for the member 'mshtml._userBITMAP.pBuffer'. TlbImp :

warning TI3016 : The type library importer could not convert the signature for the member 'mshtml._FLAGGED_BYTE_BLOB.abData'. TlbImp :

warning TI3015 : At least one of the arguments for 'mshtml.ICanvasPixel ArrayData.GetBufferPointer' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to m anipulate. TlbImp : Type library imported to d:zTempMicrosoft.mshtml.dll

  • Can these warnings be safely ignored?
  • Is there no precompiled version of this dll available for download from the microsoft site?
  • Is it ok for me to distribute this dll with my app?
  • When adding a reference to the dll to a .NET 3.5 project I was given the following warning:
  • 'Microsoft.mshtml.dll', or one of its dependencies requires a later version of the .Net Framework than the one specified in the project ...

    Since it was a warning and let me add the reference any way, can I still use certain features of the .dll in .NET 3.5?

    Thanks


    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 filesmicrosoft sdkswindowsv6.0abin. 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.

    链接地址: http://www.djcxy.com/p/58000.html

    上一篇: DateTime.Parse今天失败(2012年3月1日)! Ø

    下一篇: 如何在.NET中添加对mshtml版本9的引用