c#网络浏览器未显示内部信息

c#网络浏览器未显示内部信息,c#,webbrowser-control,C#,Webbrowser Control,(首先,对不起我的英语) 我在一个客户端中遇到了一个问题,我试图显示的消息没有出现在显示组件为空的组件中,这只在一个客户端中发生大约1000次。 从昨天开始就失败了,客户端有Windows7,我不知道他的IE版本 在这种情况下,我对newValue所做的唯一一件事就是引入一些粗体字 我无法在我的机器上重现此错误,因此任何人都知道任何可能使其失败或显示为空白的原因(Windows Update,IE版本,内部文本…) WebBroser在一个表单中,我像MessageBox一样使用它,但有了它,我

(首先,对不起我的英语) 我在一个客户端中遇到了一个问题,我试图显示的消息没有出现在显示组件为空的组件中,这只在一个客户端中发生大约1000次。 从昨天开始就失败了,客户端有Windows7,我不知道他的IE版本

在这种情况下,我对newValue所做的唯一一件事就是引入一些粗体字

我无法在我的机器上重现此错误,因此任何人都知道任何可能使其失败或显示为空白的原因(Windows Update,IE版本,内部文本…)

WebBroser在一个表单中,我像MessageBox一样使用它,但有了它,我可以打印颜色或我在消息中的其他数字

private void SetWebBrowserText(string newValue)
{
        try
        {
            if (this.webBrowser1.Document == null)
                this.webBrowser1.Navigate("about:blank");

            if (!String.IsNullOrEmpty(newValue))
                newValue = String.Concat("<div><font color=\"#000000\" size=\"2\" face=\"verdana\">", newValue.Replace("\n", "<br>"), "</font></div>");

            webBrowser1.Document.Write(newValue);
        }
        catch { }
}
private void SetWebBrowserText(字符串newValue)
{
尝试
{
if(this.webBrowser1.Document==null)
this.webBrowser1.Navigate(“关于:空白”);
如果(!String.IsNullOrEmpty(newValue))
newValue=String.Concat(“,newValue.Replace(“\n”,“
”)”); webBrowser1.Document.Write(newValue); } 捕获{} }
Vb.net:

Public Sub ShowMessage(ByVal htmlmsg As String)
    WebBrowser1.Navigate("")
    Do While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
        Application.DoEvents()
        System.Threading.Thread.Sleep(1)
    Loop
    WebBrowser1.Document.Body.InnerHtml = htmlmsg
End Sub

例子:

ShowMessage(“Msg red Msg”)

最终,我们找到了解决方案,从一个清晰的安装中重新安装整个系统,似乎框架已损坏或它的系统注册表已损坏

   public void ShowMessage(string htmlmsg)
   {
    WebBrowser1.Navigate("");
    while (WebBrowser1.ReadyState != WebBrowserReadyState.Complete) {
        Application.DoEvents();
        System.Threading.Thread.Sleep(1);
    }
    WebBrowser1.Document.Body.InnerHtml = htmlmsg;
   }
ShowMessage("<h1>Msg</h1> <h2 style='color:Red'>red msg</h2>")