AccessViolationException from System.Windows.Forms using WinFormsHost in WPF

I am facing an unpleasant problem when developing an application for interfacing WPF / WinForms. I tried to solve this problem for three days, but I cannot succeed. I doubt that I can provide enough information to get permission, but I'm looking for anyone who can explain what is happening here?

The component I'm using is AxMapControl (ESRI ArcGIS Engine 9.3.1 SP2), which, as far as I know, is a COM shell of its own code that appears as a WinForms control. The component is embedded in our WPF client software (.NET 3.5) using the WPF WinFormsHost proxy.

Periodically crashing the application using AccessViolationException. This always happens in response to a user clicking on a map control, but there seems to be no rhyme or reason for a specific input. The stack trace is always the same:

System.AccessViolationException: attempt to read or write protected memory. This often indicates that another memory is corrupted. in System.Windows.Forms.UnsafeNativeMethods.CallWindowProc (IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam) in System.Windows.Forms.NativeWindow.DefWndProc (Message & m) in System.WindowsF. DefWndProc (Message & m) in System.Windows.Forms.AxHost.WndProc (Message & m) in System.Windows.Forms.Control.ControlNativeWindow.OnMessage (Message & m) in System.Windows.Forms.Control.ControlNativeWindow.WndProc (Message & m) in System.Windows.Forms.NativeWindow.Callback (IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

, , , , , .

, . , Windows 7 XP, .NET Framework 3.5 4.0.

, , , , -, CreateFileMapping GAC , FILE LOCKED WITH ONLY READERS.

ProcMon screenshot

, , , , DLL. -?

, , , , . , , ?

?

+3
1

, ESRI, : , COM, Windows Forms, WPF WindowsFormsHost. System.AccessViolationException, , .

: WPF , , - WPF , / ( / ). WPF UserControl.Loaded(WPF). , WPF Loaded, - . 0 height, 0 width, , . , , (x, y) AccessViolationException.

, , UserControl.Resize, , , , , bool mapIsInitialized WPF, , , , . (, ), , mapIsInitialized.

, , , , , , , .

!

+1

Source: https://habr.com/ru/post/1792552/


All Articles