473,395 Members | 1,639 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,395 software developers and data experts.

System.AccessViolationException: Attempted to read or write protected memory

Hi friends,

I am facing one serious problem in my application.
I am trying to open dicom image file (.dcm) has size around 400 MB.
But I am getting and unhandy exceptions,

Some time,

{System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at ?readMedia@BASE_SESSION_CLASS@@$$FQAEPAVFILE_DATAS ET_CLASS@@V?$basic_string@DU?$char_traits@D@std@@V ?$allocator@D@2@@std@@W4MEDIA_FILE_CONTENT_TYPE_EN UM@@000_N2@Z(BASE_SESSION_CLASS* , basic_string<char\,std::char_traits<char>\,std::al locator<char> >* , Int32 , basic_string<char\,std::char_traits<char>\,std::al locator<char> >* , basic_string<char\,std::char_traits<char>\,std::al locator<char> >* , basic_string<char\,std::char_traits<char>\,std::al locator<char> >* , Boolean , Boolean )
at Wrappers.MBaseSession.ReadMedia(String pFileName)
at Dvtk.Sessions.Session.ReadFile(String mediaFileName)
at DvtkHighLevelInterface.Dicom.Files.DicomFile.Read( String fullFileName, ScriptSession dvtkScriptSession)
at DvtkHighLevelInterface.Dicom.Files.DicomFile.Read( String fullFileName, String[] definitionFilesFullName)
at _3disytems.DicomAnonymiserLibrary.DicomImageProces sor.ModifyDicomFile(String filePath) in E:\Projects\Working\Dicom Project\DicomEditorLibrary\DicomImageProcessor.cs: line 63}


and Some times

{System.Runtime.InteropServices.SEHException: External component has thrown an exception.
at ?readMedia@BASE_SESSION_CLASS@@$$FQAEPAVFILE_DATAS ET_CLASS@@V?$basic_string@DU?$char_traits@D@std@@V ?$allocator@D@2@@std@@W4MEDIA_FILE_CONTENT_TYPE_EN UM@@000_N2@Z(BASE_SESSION_CLASS* , basic_string<char\,std::char_traits<char>\,std::al locator<char> >* , Int32 , basic_string<char\,std::char_traits<char>\,std::al locator<char> >* , basic_string<char\,std::char_traits<char>\,std::al locator<char> >* , basic_string<char\,std::char_traits<char>\,std::al locator<char> >* , Boolean , Boolean )
at Wrappers.MBaseSession.ReadMedia(String pFileName)
at Dvtk.Sessions.Session.ReadFile(String mediaFileName)
at DvtkHighLevelInterface.Dicom.Files.DicomFile.Read( String fullFileName, ScriptSession dvtkScriptSession)
at DvtkHighLevelInterface.Dicom.Files.DicomFile.Read( String fullFileName, String[] definitionFilesFullName)
at _3disytems.DicomAnonymiserLibrary.DicomImageProces sor.ModifyDicomFile(String filePath) in E:\Projects\Working\Dicom Project\DicomEditorLibrary\DicomImageProcessor.cs: line 63}


These exception not getting for every files, only for large files when I am trying to read them.

I am using DVTK Library for Dicom images provided by DVTK. It's open source
http://www.dvtk.org

Following code ex I am using..

Expand|Select|Wrap|Line Numbers
  1. public static void ModifyDicomFile(string filePath)
  2.         {
  3.             DicomFile theDicomFile;
  4.             try
  5.             {
  6.                 theDicomFile = new DicomFile();
  7.                 theDicomFile.Read(filePath);
  8.  
  9.                 if (attrInfo.PatientName == null || attrInfo.PatientName == "" || attrInfo.PatientID == null || attrInfo.PatientID == "" || attrInfo.PatientDOB == null || attrInfo.PatientDOB == "")
  10.                     Logger.Log(dirSettings.LogDirectory, "some information of Patient is missing in App.config");
  11.  
  12.                 theDicomFile.DataSet.Set("0x00100010", VR.PN, attrInfo.PatientName);
  13.                 theDicomFile.DataSet.Set("0x00100020", VR.LO, attrInfo.PatientID);
  14.                 theDicomFile.DataSet.Set("0x00100030", VR.DA, attrInfo.PatientDOB);
  15.  
  16.                 string relPath;
  17.  
  18.                 if (!filePath.Contains(".dcm"))
  19.                 {
  20.                     relPath = dirSettings.TargetDirectory + filePath.Substring(dirSettings.SourceDirectory.Length) + ".dcm";
  21.                 }
  22.                 else
  23.                 {
  24.                     relPath = dirSettings.TargetDirectory + filePath.Substring(dirSettings.SourceDirectory.Length);
  25.                 }
  26.  
  27.                 theDicomFile.Write(relPath);
  28.  
  29.                 // File.Delete(filePath);
  30.             }
  31.             catch (Exception e)
  32.             {
  33.                 Logger.Log(dirSettings.LogDirectory, "Error: Dicom File Modification : " + e.Message);
  34.             }
  35.         }  

I am want to tell you that this is working for small files(2-5mb) but it giving problem me when I am trying to read 400MB files

Please solve this problem.
This is .Dot net only

Thanks,
Manesh
Jan 15 '10 #1
3 5842
tlhintoq
3,525 Expert 2GB
How much free memory does your PC have?
Maybe you are just running out of RAM.
Jan 15 '10 #2
Hi,

I have 2 GB of RAM, 4-8 GB Virtual Memory set. And when I run the application lot of memory unused.

but still it is not working.
Jan 15 '10 #3
alexis4
113 100+
Access violation exceptions come from bad interop calls or unmanaged code. Do you have any dll function calls? Do you use unsafe code? Are low level API calls involved with your project?
Or you can simply run out of memory as tlhintoq said.. Or a part of your memory could be ruined.
This thing is tricky, so give us a little more clues. Above how much mb does this happen? It happens always on the same files or sometimes you open it and sometimes not? Are you using an unhandled exception event to catch it and it is by-passed?
Jan 15 '10 #4

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

Similar topics

9
by: hiralparikh | last post by:
Hi, I am using .NET 2.0 and trying to use a function from a native DLL file. Here is the syntax that I am using: definition: public static extern String getPwd(String strServerName, String...
2
by: humbleaptience | last post by:
I have a web application that uses a DLL using DLLImport. Twice I have put the application live on the net and it has been used hundreds or thousands of time before it has been strangely brought...
2
by: Ilkka | last post by:
I have created an C++ application with Windows Forms, ADO and SQL server 2005. Now I need to change something and started debugging the code. Then suddenly I receive an error. "An unhandled...
2
by: Pieter | last post by:
Hi, Since 10 days (the first time was the 10th of november) I have some weird exception happening in an application here: All (except 1 of the total of 5) users had this error now 1 of 2 times...
1
by: Bruce | last post by:
I am getting the following exception in the release build of my assembly. {"Attempted to read or write protected memory. This is often an indication that other memory is...
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...
1
by: Marc Bartsch | last post by:
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. From...
6
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the...
1
by: mabubakarpk | last post by:
I am using asp.net framework 2.0. I am facing following error message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" For more detail Plz...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.