问题
We are using an outlook addin (visual basic .NET framework 4 client profile, office 365 business 16.0.11727.20230) that displays some content within a WebBrowser
control. I'm not that familiar with visual basic because someone else created this addin and he is not available anymore now, so first of all sorry if i made any basic mistake.
Actually the control should display some .xml content but to simplify the question im just trying to display the webpage https://www.google.at for the moment. Displaying the content within this plugin was always working and since the last windows/office update all i get is a white screen with no code error. If i create a new windows forms application with the same control that runs without outlook the content is displayed without any problems (uri and the actual .xml) so i assume it has something to do with new outlook security settings or something like this.
The control uses the lib Windows.Forms.WebBrowser and the url is set like this:
Public Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim url = "https://www.google.at"
Call WebBrowser1.Navigate(New System.Uri(url))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
I already figured out, that the control displays my content if i enable the setting 'optimize for compatibility' under files/general options but actually i'd like that it displays the content without using that setting because i think that should not be necessary.
Another way to display the content would be to use the "Microsoft Web Browser" (AxSHDocVw.AxWebBrowser) control. This one displays my content too but has an older UI and i can't figure out how to disable the scrollbars with this one. Don't know if this information helps to figure out why the System.Windows.Forms control does not display the content.
Thanks for any help or suggestions how i get my control back to display some content within.
回答1:
The WebBrowser
control is a managed wrapper for the ActiveX WebBrowser
control, and uses whichever version of the control is installed on the user's computer.
The WebBrowser control cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
The WebBrowser class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main
method is marked with the STAThreadAttribute attribute.
来源:https://stackoverflow.com/questions/56863707/outlook-addin-visual-basic-windows-forms-application-webbrowser-control-cont