Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using C# windows applications(VS 2010). I create new object from 3rd party ocx as

C#
 Axx.AxView ax = new Axx.AxView();

And I add this to a form dynamically.

                    frmDummy = new Form();
                    frmDummy.Height = 0;
                    frmDummy.Width = 0;
                    frmDummy.Visible = false;
                    frmDummy.ControlBox = false;
                    frmDummy.WindowState = FormWindowState.Minimized;
                    frmDummy.Show();
                    frmDummy.Controls.Add(ax);


When I'm assigning any property to this object exception coming (eg. ax.FileName="sss.xls")
AccessViolationException:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Posted
Updated 4-Jul-12 18:06pm
v2

try
C#
frmDummy.Controls.Add(ax);
frmDummy.Show();
 
Share this answer
 
Comments
Sanyon_d 5-Jul-12 0:25am    
Thanks for reply. It didn't work. This happens only in windows7 platform. In windows xp it works nice. Is there any security settings need to be changed in windows7
Is that Axx.AxView a 32bit assembly, or does it depend on a 32bit assembly? If so, change the target of your solution to x86.
Does that Third Party control try to write to e.g. C:\Window or other places where an applcation must not write to? Then: no chance to get it running.
There could be a problem with Data Execution Protection - switch it off for test purposes.
If you create an application with it on a Windows XP machine, does that application work on Windows 7?
 
Share this answer
 
Comments
Sanyon_d 5-Jul-12 22:39pm    
Thanks for the reply
I used same concept with visual foxpro.Then it works in both xp and windows 7.
This doesn't write anything to the system. This ocx used to open CAD files.
If exe built in windows xp even it doesn't work in the windows 7.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900