The 2nd error causes the first one. Open the project's References node, select SHDocVw. In the Properties window, change "Embed Interop Types" to false. You will have to deploy the Interop.SHDocVw.dll assembly you'll find the build output directory along with your program.
EDIT: after researching this error, I found a better way to do this. The issue is that only COM interface types can be embedded, not classes. So avoid using the synthetic XxxxClass wrappers in your code. Make it look like this instead:
foreach (InternetExplorer ie in new ShellWindows()) {
//...
}
Which looks strange, you cannot normally use the new operator on an interface type in the C# language. But is actually supported for COM interfaces.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…