NullReferenceException

Status
Niet open voor verdere reacties.

rswillens

Nieuwe gebruiker
Lid geworden
12 apr 2015
Berichten
2
Kan iemand mij helpen ik zit vast met het volgende.
Ik probeer een belgische id kaart uit te lezen met onderstaande code.
Ik heb twee idkaarten wat er mijn inziens het zelfde uit zien alleen bij 1 kaart krijg ik constant een nNullReferenceException
Hellp!!
thx :D

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EIDLIBCTRLLib;

namespace Test1
{
    public partial class Form1 : Form
    {
        string gebDatum;
        
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Resize(object sender, EventArgs e)
        {
            this.panel1.Width = this.Width - 100;
            this.panel1.Height = this.Height - 100;

            this.panel4.Location = new Point(this.panel4.Location.X, this.panel1.Height - this.panel4.Height - 50);
        }
  


        private void button4_Click(object sender, EventArgs e)
        {

            
            EIDlib EIDlib1 = new EIDlib();
            
            CertifCheck CertifCheck = new CertifCheck();

            MapCollection MapColID =  new MapCollection();
            MapCollection MapColAdress = new MapCollection();
            int lHandle = 1;

            RetStatus RetStatus;
            IRetStatus test;
            
            
            RetStatus = EIDlib1.Init("", 0, 0, out lHandle);
            RetStatus = EIDlib1.GetID(out MapColID, out CertifCheck);
            
            RetStatus.SetGeneral(0);

            if (RetStatus.GetGeneral() == 1)
            {
                MessageBox.Show("Geen kaart aanwezig");
            }
            else
            {
                try
                {
                    this.gebDatum = (MapColID.GetValue("BirthDate"));
                    Console.WriteLine(gebDatum.ToString());
                }
                catch(NullReferenceException ce)
                {
                    MessageBox.Show(ce.ToString());
                }
                
                //MessageBox.Show(MapColID.GetValue("CardNumber"));
                //MessageBox.Show(MapColID.GetValue("FirstName1"));
                
                //RetStatus = EIDlib1.GetID(out MapColAdress, out CertifCheck);
                //MessageBox.Show(MapColAdress.GetValue("Street"));

            }
            

            
        } 



    }
}
 
kijk eens of je MapColID niet null is of wel een value "BirthDate" heeft
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan