473,378 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

i Get System.AccessViolationException was unhandled

Hi,

My C# app throws the following exception:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Expand|Select|Wrap|Line Numbers
  1. static void Main()
  2.         {
  3.             Application.EnableVisualStyles();
  4.             Application.SetCompatibleTextRenderingDefault(false);          
  5.             Application.Run(new Login());  // get exception at this line(wen i try to enter details in text box)        
  6.  
  7.         }
The stack trace is as follows :
" at System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)\r\n at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)\r\n at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)\r\n at System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context)\r\n at WindowsFormsApplication1.Program.Main() in D:\\TRUPTI\\02-02-2013-RNSB WithPaymentEdit\\RNSB\\RNSB\\Program.cs:line 25\r\n at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()\r\n at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ThreadHelper.ThreadStart()"
Mar 20 '13 #1
8 12915
r035198x
13,262 8TB
This is a difficult one to be honest. Possibilities are

1.) Some unmanaged (perhaps non C#) code is causing this and you might be only getting this in development and not in production. Doing Tools menu ->Options -> Debugging -> General -> and unchecking the option "Suppress JIT optimization on module load" might make it disappear from your dev environment. If you are in control of the unmanaged code invocations try disabling some of them to see if you can pin point the one that is problematic.


2.) It could be that there are some components that you not disposing of properly

3.) You could be using .NET 2.0 which has a bug that was fixed with this patch http://support.microsoft.com/kb/971030
Mar 20 '13 #2
can u suggest any other fix to this problem. i tried the first one. it didn't work out .
Mar 23 '13 #3
r035198x
13,262 8TB
Did you check for 2 and 3 then?
Mar 23 '13 #4
yes . i did try the 2nd and 3rd options.. i also tried to run this project in another PC. its runs perfectly fine. so according to my knowledge there is no issues with coding. i m not able to figure out the where the problem lies..
Mar 25 '13 #5
r035198x
13,262 8TB
Are the different PCs that you tried the same .NET versions and OS as the PC where it fails?
Mar 25 '13 #6
yes... same .net frame work is installed. In my PC OS is windows 7 ultimate, and in the other its windows 7 enterprise.
Mar 25 '13 #7
Problem solved. the project bus built on 32 bit operating system and i was trying to run on 64 bit operating system.
Goto configuration manager platform select the appropriate platform
Mar 28 '13 #8
r035198x
13,262 8TB
Thanks for posting back your solution.
Mar 28 '13 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: James Arnold | last post by:
I am getting the following error message in my WinForms project: --- An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll Additional...
5
by: deepakkumarb | last post by:
I am getting this exception while executing non query from .NET code to oracle 10g DB. Can you plz help System.AccessViolationException: Attempted to read or write protected memory. This is...
0
by: Dilip | last post by:
I have cross-posted this question to 3 newsgroups since I am not sure exactly where it belongs (and some NG's have very less activity). Apologies in advance for this. I have set the followup to...
2
by: mcfly1204 | last post by:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt. I have looked into the issue with varied results. With ASP.NET applications, most people can...
0
by: mikeosoft | last post by:
Hi there, this is my first post here! I hope someone can help me. What I'm trying to do is : Storing Fonts in SQL Server And recalling them without installing the file in Windows\Fonts So I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.