Попробовал создать WPF приложение с компонентом карты Zulu. При использовании WindowsFormsHost происходит ошибка переполнения стека. Этот же WPF код использовался для работы с com-объектами MapInfo MapXtreme - все работало нормально.
MS VS2010 выдает ошибку An unhandled exeption of type 'System.StackOverflowException' occured in PresentationFramework. Детального разбора нет, т.к {Cannot evaluate expression because the current thread is in a stack overflow state.}
public MainWindow() { InitializeComponent(); _windowsFormsMapHost2 = new WindowsFormsHost(); _axMapCtrl1 = new AxZuluOcx.AxMapCtrl(); _axMapCtrl1.BackColor = System.Drawing.Color.Red; _axMapCtrl1.Dock = DockStyle.Fill; _windowsFormsMapHost2.Child = _axMapCtrl1;
MainGrid.Children.Add(_windowsFormsMapHost2); } Встраивание карты в хост не вызывает ошибки. Как только хост добавляется в дочерние элементы Grid возникает уже немного по-другому сформулированная ошибка - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
Пробовал определять в code behind и в xaml - результат одинаковый.
Ошибка "Переполнение или потеря точности в арифметической операции."
Stack Trace:
в System.Windows.Size.op_Inequality(Size size1, Size size2) в System.Windows.Forms.Integration.WindowsFormsHost.ArrangeOverride(Size finalSize) в System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) в System.Windows.UIElement.Arrange(Rect finalRect) в System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize) в System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) в System.Windows.UIElement.Arrange(Rect finalRect) в MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize) в System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize) в System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) в System.Windows.UIElement.Arrange(Rect finalRect) в System.Windows.Controls.Decorator.ArrangeOverride(Size arrangeSize) в System.Windows.Documents.AdornerDecorator.ArrangeOverride(Size finalSize) в System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) в System.Windows.UIElement.Arrange(Rect finalRect) в System.Windows.Controls.Border.ArrangeOverride(Size finalSize) в System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) в System.Windows.UIElement.Arrange(Rect finalRect) в System.Windows.Window.ArrangeOverride(Size arrangeBounds) в System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) в System.Windows.UIElement.Arrange(Rect finalRect) в System.Windows.Interop.HwndSource.SetLayoutSize() в System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value) в System.Windows.Interop.HwndSource.set_RootVisual(Visual value) в System.Windows.Window.SetRootVisual() в System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight) в System.Windows.Window.CreateSourceWindowImpl() в System.Windows.Window.SafeCreateWindow() в System.Windows.Window.ShowHelper(Object booleanBox) в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) в System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) в System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) в System.Windows.Threading.DispatcherOperation.InvokeImpl() в System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) в System.Threading.ExecutionContext.runTryCode(Object userData) в System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) в System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) в System.Windows.Threading.DispatcherOperation.Invoke() в System.Windows.Threading.Dispatcher.ProcessQueue() в System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) в MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) в MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) в System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) в System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) в System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) в System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) в MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) в MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) в System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) в System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) в System.Windows.Threading.Dispatcher.Run() в System.Windows.Application.RunDispatcher(Object ignore) в System.Windows.Application.RunInternal(Window window) в System.Windows.Application.Run(Window window) в System.Windows.Application.Run() в _ZuluWPFProj.App.Main() в D:\Projects\_ProbeProjects\_ZuluWPFProj\_ZuluWPFProj\obj\x86\Debug\App.g.cs:строка 0 в System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) в System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() в System.Threading.ThreadHelper.ThreadStart_Context(Object state) в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) в System.Threading.ThreadHelper.ThreadStart()