Robert Apostolico
Guest
|
Hello Support,
I'm working with an add-in that needed to determine if a particular style sheet is installed.
So, borrowing from a CSS example project, in the IEModule_DocumentComplete2 event, I check if the rootDocLoaded and if the domain is the target url. If so, I call the RegisterCSS method.
In the RegisterCSS method, I'm trying to loop through the document's style sheets.
I can properly access HTMLDocument.styleSheets.length; that comes back as a 2.
But if I try to access HTMLDocument.styleSheets.item(0) or (1), I'll get an error (in immediate window) that the Predefined type 'Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported.
In both the IE extension project and the broker project, I made a reference to Microsoft.CSharp assembly.
Additionally, if I try to browse/drill-into the object to retrieve its values while debugging, I'll click the @ refresh icon for the debugger to grab the current values of the COM enumeration, and I'll get the below error message:
the type 'mshtml.HTMLStyleSheetsCollectionClass' exists in both MSHTML.dll and MSHTML.dll
What is happening?
Please advise.
Thank you. |
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Robert,
What version of PIAs do you use in your project (Microsoft.mshtml and Interop.SHDocVw.dll)? Probably you use several versions of PIAs (Add-in Express + ActiveX)? |
|
Robert Apostolico
Guest
|
Sergey,
Yes, it seems both of those files are referenced:
interop.MSHTML.dll and
interop.SHDocVw.dll
I've been experimenting with different project types.
On my current path, I'm pretty much looking to only use the IEModule and a Command Item button.
which reference should I remove?
Thank you! |
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Robert,
Both references are correct. Can you send me a simple project that reproduces this issue? |
|
Robert Apostolico
Guest
|
Sergey,
Many times, while experimenting with new technologies, I'll use the object browser to get an idea of what an object may look like, and at run-time use a watch-window to drill-into live data-values to see how its actually populated and really put together.
Running the project directly does not seem to produce the problem.
However, I can make the problem happen by setting a break-point in my code, and while debugging, try to evaluate HTMLDocument.styleSheets.item(0) in the immediate window. The IDE/debugger comes up with the unhandled exception. ( And yes, there is data in the object, HTMLDocument.styleSheets.Length = 2 ).
Thank you. |
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Robert,
Please try to cast 'HTMLDocument.styleSheets.item(N)' to the stylesheet object in the code and then you will be able to inspect it in the immediate window.
mshtml.IHTMLStyleSheet ssheet = HTMLDocument.styleSheets.item(0) as mshtml.IHTMLStyleSheet; |
|