添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hello,
I am using c# Hydra WPF form for web browser navigation and invoking this application from my Delphi application. I ran into an issue when I tried to make the Hydra WPF form as child form for my Delphi application main form. Could you please advise how to resolve this error.

Here is the complete information of the error
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidOperationException: BuildWindowCore failed to return the hosted child window handle.
at System.Windows.Interop.HwndHost.BuildWindow(HandleRef hwndParent)
at System.Windows.Interop.HwndHost.BuildOrReparentWindow()
at System.Windows.Interop.HwndHost.OnSourceChanged(Object sender, SourceChangedEventArgs e)
at System.Windows.SourceChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.PresentationSource.UpdateSourceOfElement(DependencyObject doTarget, DependencyObject doAncestor, DependencyObject doOldParent)
at System.Windows.PresentationSource.RootChanged(Visual oldRoot, Visual newRoot)
at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
at System.Windows.Forms.Integration.ElementHost.b__54_0()
at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke(Action callback)
at System.Windows.Forms.Integration.ElementHost.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Integration.ElementHost.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll

RemObjects.Hydra
Assembly Version: 6.0.93.1189
Win32 Version: 6.0.93.1189
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/RemObjects.Hydra/6.0.93.1189__3df3cad1b7aa5098/RemObjects.Hydra.dll

CC.Quantum.BI
Assembly Version: 1.0.6862.22945
Win32 Version: 1.0.6862.22945
CodeBase: file:///C:/dotnet/Power%20BI/CC.Quantum.BI/CC.Quantum.BI/bin/Debug/CC.Quantum.BI.DLL

PresentationFramework
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3081.0
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.dll

WindowsBase
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3081.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/WindowsBase/v4.0_4.0.0.0__31bf3856ad364e35/WindowsBase.dll

System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3081.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

System
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

PresentationCore
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3081.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/PresentationCore/v4.0_4.0.0.0__31bf3856ad364e35/PresentationCore.dll

RemObjects.Hydra.WPF
Assembly Version: 6.0.93.1189
Win32 Version: 6.0.93.1189
CodeBase: file:///C:/dotnet/Power%20BI/CC.Quantum.BI/CC.Quantum.BI/bin/Debug/RemObjects.Hydra.WPF.DLL

System.Xaml
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3081.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xaml/v4.0_4.0.0.0__b77a5c561934e089/System.Xaml.dll

System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

PresentationFramework.Aero
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework.Aero/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.Aero.dll

System.Net.Http
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Net.Http/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Net.Http.dll

Newtonsoft.Json
Assembly Version: 11.0.0.0
Win32 Version: 11.0.2.21924
CodeBase: file:///C:/dotnet/Power%20BI/CC.Quantum.BI/CC.Quantum.BI/bin/Debug/Newtonsoft.Json.DLL

System.Runtime.Serialization
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll

System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll

System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3081.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll

WindowsFormsIntegration
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/WindowsFormsIntegration/v4.0_4.0.0.0__31bf3856ad364e35/WindowsFormsIntegration.dll

UIAutomationTypes
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3081.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/UIAutomationTypes/v4.0_4.0.0.0__31bf3856ad364e35/UIAutomationTypes.dll

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Unfortunately I cannot reproduce the issue:

2018-10-17_14-16-42_UnmanagedHost.png 1017×755 19.1 KB

This is a simple Host app from samples and a WPF plugin with this XAML:

<hydra:VisualPlugin x:Class="ManagedCSharpWpfPluginModule.WpfCSharpPlugin"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:hydra="clr-namespace:RemObjects.Hydra.WPF;assembly=RemObjects.Hydra.WPF"
    Height="300" Width="300">
      <WebBrowser RenderTransformOrigin="0.063,0.043"
                  x:FieldModifier="public"
                  x:Name="webBrowser"
                  Margin="0,0,10,0"
                  Source="https://example.com"/>
  </Grid>
</hydra:VisualPlugin>

Could you please create a testcase where this issue is reproduced? Use the unmanaged host and WPF plugin samples from this folder c:\Users\Public\Documents\RemObjects Samples\Hydra for NET\Mixed Mode as a starting point.

Also could you double-check that the WebBrowser does work for you is a standalone WPF app with similar markup to ensure that this is not a local system issue?

Thanks in advance

Ah, you tried to host the WPF plugin in an invisible Delphi form? That explains the exception you got. It seems that the WebBrowser component requires its host windows to be visible (or at least to have a Window handle). Otherwise it will fail. It is not a Hydra, plugin or host code fault - it is just the way this particular component behaves.