![](/img/trans.png)
[英]WPF userControl containing an image image doesnt resize when usercontrol is resized
[英]FatalExecutionEngineError when closing WPF UserControl containing WebBrowser
我有以下基本XAML:
<Window x:Class="SomeControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<WebBrowser x:Name="webBrowser"></WebBrowser>
</Grid>
</Window>
當我試圖關閉包含用戶控件的選項卡時,我收到以下錯誤:
托管調試助手'FatalExecutionEngineError'檢測到'Some.vshost.exe'中存在問題。
附加信息:運行時遇到致命錯誤。 錯誤的地址是0x7ba6a66f,位於線程0x3bd0上。 錯誤代碼是0x80131623。 此錯誤可能是CLR中的錯誤,也可能是用戶代碼的不安全或不可驗證部分中的錯誤。 此錯誤的常見來源包括COM-interop或PInvoke的用戶編組錯誤,這可能會破壞堆棧。
我試圖調用WebBrowser.Dispose()
但它返回相同的錯誤
我們遇到了同樣的問題。 我們嘗試手動處理控件,但問題仍然存在。 最后,我們使用了System.Windows.Forms命名空間中的WindowsFormsHost組件和WebBrowser。
<Window x:Class="SomeControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="_webBrowserGrid>
</Grid>
</Window>
在代碼中:
var host = new System.Windows.Forms.Integration.WindowsFormsHost();
System.Windows.Forms.WebBrowser _webBrowser = new System.Windows.Forms.WebBrowser();
host.Child = _webBrowser;
this._webBrowserGrid.Children.Add(host);
_webBrowser.Navigate("http://www.google.com");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.