I have a .NET application and a setup fot it. Built using VS 2005.
The development machine is Windows XP SP3.
Once somebody installed it under Windows7. And get the following errors
WinForm ThreadException
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at System.Windows.Forms.UnsafeNativeMethods.IOleObject.DoVerb(Int32 iVerb, IntPtr lpmsg, IOleClientSite pActiveSite, Int32 lindex, IntPtr hwndParent, COMRECT lprcPosRect) at System.Windows.Forms.AxHost.DoVerb(Int32 verb) at System.Windows.Forms.AxHost.InPlaceActivate()
other one
Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown. Method 'Disconnect' cannot be invoked at this time.
Now, wondered where was the problem, and installed VS 2005 on this Windows7. Now, the solution compiles and runs without exceptions. I built the setup, and reinstalled the newly built setup on this Win7 machine...
I got the exceptions. Why this?
The applications have no exceptions launched with VS, but throws it when after launching the installed executable...
However, I successfully (without exceptions) tested the installed application on some machines with the OS > Win XP: Windows 7 (x64) and the Windows Server 2008 (x64) ...
Studying the logs, I discovered the code that produces the exception:
Panel p = new Panel();
p.Margin = new Padding(0);
p.Dock = DockStyle.Fill;
p.Controls.Add(display); // 'display' is an ActiveX control instance
Logger.LogMessage("before");
this.tableLayoutPanel.Controls.Add(p); // protected memory EXCEPTION
Logger.LogMessage("after");
So, I see "before" then AccessViolationException: Attempted to read or write protected memory...
don't see "after"...
What are the common causes for such an exceptions?
Details
- I use some third party ActiveX in the application;
- Samples (written in C++) using that ActiveX runs well on this machine.
- The solution targets the x86 platform;
- I managed to launch without errors the application on **Windows Server 2008 (x64) and on Windows 7 (x64);
- Tried using 'Windows XP Compatibility (SP2, SP3)' mode - the same result (exceptions).
- Tried to install the application in an other folder that
ProgramFiles
. I used C:\TestFolder as installation path - the result is the same: AccesViolationException....