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?
ProgramFiles. I used C:\TestFolder as installation path - the result is the same: AccesViolationException....Wow, an x84 CPU, never seen one of those ;-)) What you mean is probably x64...
Your Windows XP installation is a 64 Bit one ?
It's probably a 32/64-Bit conversion issue, and not a Windows 7 issue.
Forms.UnsafeNativeMethods.IOleObject
Do you pinvoke your ActiveX dll ?
Is it a 32 bit dll or a 64 bit dll ? 32 bit dll's won't run in a 64 bit environment and vice-versa.
If you call it via COM, you might have a chance. But at least on Linux, the C/C++ datatype long has 8 Bytes in 64 bit mode, while it has 4 Bytes in 32 bit mode.
Try targetting the x86 platform (=32 Bit) in the .NET application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With