Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends,
i was using fingerprint reader in my application.i getting the fingerprint in image box.for some time the following exception occur how could i solve this. please help
execption:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

this is the code where i get exception:
C#
protected override void WndProc(ref Message message)
     {
         try
         {
             switch (message.Msg)
             {
                 case Win32.WM_DEVICECHANGE: OnDeviceChange(ref message);
                 break;
             }
             if (message.Msg == (int)SGFPMMessages.DEV_AUTOONEVENT)
             {
                 if (message.WParam.ToInt32() == (Int32)SGFPMAutoOnEvent.FINGER_ON)
                 {
                     Int32 iError;
                     Byte[] fp_image;
                     Int32 img_qlty;
                     fp_image = new Byte[m_ImageWidth * m_ImageHeight];
                     img_qlty = 0;
                     iError = m_FPM.GetImage(fp_image);
                     m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);
                     if (iError == (Int32)SGFPMError.ERROR_NONE)
                     {
                         DrawImage(fp_image, pictureBoxR1);
                         iError = m_FPM.CreateTemplate(null, fp_image, m_RegMin1);
                         if (iError == (Int32)SGFPMError.ERROR_NONE)
                         {
                             lblmessage.Text = "Image for verification is captured";
                             btnconnect.Text = "Fingerprint Connected";
                             btnconnect.ForeColor = System.Drawing.Color.WhiteSmoke;
                             btnconnect.BackColor = System.Drawing.Color.MediumSeaGreen;
                             m_FPM.EnableAutoOnEvent(true, (int)this.Handle);
                             verification();
                         }
                         else
                         {
                             DisplayError("CreateTemplate()", iError);
                         }
                     }
                     else
                     {
                         DisplayError("GetImage()", iError);
                     }
                 }
                 else if (message.WParam.ToInt32() == (Int32)SGFPMAutoOnEvent.FINGER_OFF)
                 {
                     lblmessage.Text = "Device Message: Finger Off";
                 }
                 //m_RegMin1 = null;
             }
             base.WndProc(ref message);
         }
         catch(Exception ex)
         {
         }
     }
Posted
Updated 13-Feb-12 19:52pm
v2
Comments
Sergey Alexandrovich Kryukov 14-Feb-12 0:37am    
Isn't that obvious: there is no enough information?!
Please understand that we don't have access to your hard drive. Today I had a pretty difficult day, so my ability to read your mind is also a bit dull :-)

There are different ways to screw up thing; I cannot see which one you have chosen this time :-)
--SA
parithi vr 14-Feb-12 1:50am    
ok this is the code

protected override void WndProc(ref Message message)
{
try
{
switch (message.Msg)
{
case Win32.WM_DEVICECHANGE: OnDeviceChange(ref message);
break;
}
if (message.Msg == (int)SGFPMMessages.DEV_AUTOONEVENT)
{
if (message.WParam.ToInt32() == (Int32)SGFPMAutoOnEvent.FINGER_ON)
{
Int32 iError;
Byte[] fp_image;
Int32 img_qlty;
fp_image = new Byte[m_ImageWidth * m_ImageHeight];
img_qlty = 0;
iError = m_FPM.GetImage(fp_image);
m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);
if (iError == (Int32)SGFPMError.ERROR_NONE)
{
DrawImage(fp_image, pictureBoxR1);
iError = m_FPM.CreateTemplate(null, fp_image, m_RegMin1);
if (iError == (Int32)SGFPMError.ERROR_NONE)
{
lblmessage.Text = "Image for verification is captured";
btnconnect.Text = "Fingerprint Connected";
btnconnect.ForeColor = System.Drawing.Color.WhiteSmoke;
btnconnect.BackColor = System.Drawing.Color.MediumSeaGreen;
m_FPM.EnableAutoOnEvent(true, (int)this.Handle);
verification();
}
else
{
DisplayError("CreateTemplate()", iError);
}
}
else
{
DisplayError("GetImage()", iError);
}
}
else if (message.WParam.ToInt32() == (Int32)SGFPMAutoOnEvent.FINGER_OFF)
{
lblmessage.Text = "Device Message: Finger Off";
}
//m_RegMin1 = null;
}
base.WndProc(ref message);
}
catch(Exception ex)
{
}
}
OriginalGriff 14-Feb-12 2:54am    
Where is the error occuring?
Do you get a line reference, or have you added any tracing to try to narrow it down?
parithi vr 14-Feb-12 4:29am    
error is in this line
iError = m_FPM.CreateTemplate(null, fp_image, m_RegMin1);
in the above code.

1 solution

"error is in this line"
C#
iError = m_FPM.CreateTemplate(null, fp_image, m_RegMin1);

Then you need to look at what the method does - and in particular what parameters it is expecting, and what it will do with them.
We can't look at a method call to an unknown object (as in: we don't even know what class m_FPM is, let alone what it does) and say: "it's parameter 1, it should be 6 instead of null" - we don't know anything about the method.

Sorry, but we can't help you, based on that information!
 
Share this answer
 

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