0

It has been a week, and i'm still stuck at this error, I am using the sample application files and integrate it with mine.

The exception thrown is this: "Error 1 The type or namespace name 'Function' could not be found (are you missing a using directive or an assembly reference?)

Take note: When I removed the delegate Function(), this warning showed up during runtime:

"Warning 2 A reference was created to embedded interop assembly 'c:\Program Files\DigitalPersona\One Touch SDK.NET\Bin\DPFPCtlXTypeLibNET.dll' because of an indirect reference to that assembly created by assembly 'c:\Program Files\DigitalPersona\One Touch SDK.NET\Bin\DPFPGuiNET.dll'. Consider changing the 'Embed Interop Types' property on either assembly. "

Here is the Capture Form

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    namespace Enrollment
    {
    /* NOTE: This form is a base for the EnrollmentForm and the VerificationForm,
        All changes in the CaptureForm will be reflected in all its derived forms.
    */

    public partial class CaptureForm : Form, DPFP.Capture.EventHandler
    {
        public CaptureForm()
        {
            InitializeComponent();
        }

        protected virtual void Init()
        {
            try
            {
                Capturer = new DPFP.Capture.Capture();              // Create a capture operation.

                if ( null != Capturer )
                    Capturer.EventHandler = this;                   // Subscribe for capturing events.
                else
                    SetPrompt("Can't initiate capture operation!");
            }
            catch
            {               
                MessageBox.Show("Can't initiate capture operation!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);            
            }
        }

        protected virtual void Process(DPFP.Sample Sample)
        {
            // Draw fingerprint sample image.
            DrawPicture(ConvertSampleToBitmap(Sample));
        }

        protected void Start()
        {
            if (null != Capturer)
            {
                try
                {
                    Capturer.StartCapture();
                    SetPrompt("Using the fingerprint reader, scan your fingerprint.");
                }
                catch
                {
                    SetPrompt("Can't initiate capture!");
                }
            }
        }

        protected void Stop()
        {
            if (null != Capturer)
            {
                try
                {
                    Capturer.StopCapture();
                }
                catch
                {
                    SetPrompt("Can't terminate capture!");
                }
            }
        }

    #region Form Event Handlers:

        private void CaptureForm_Load(object sender, EventArgs e)
        {
            Init();
            Start();                                                // Start capture operation.
        }

        private void CaptureForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            Stop();
        }
    #endregion

    #region EventHandler Members:

        public void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
        {
            MakeReport("The fingerprint sample was captured.");
            SetPrompt("Scan the same fingerprint again.");
            Process(Sample);
        }

        public void OnFingerGone(object Capture, string ReaderSerialNumber)
        {
            MakeReport("The finger was removed from the fingerprint reader.");
        }

        public void OnFingerTouch(object Capture, string ReaderSerialNumber)
        {
            MakeReport("The fingerprint reader was touched.");
        }

        public void OnReaderConnect(object Capture, string ReaderSerialNumber)
        {
            MakeReport("The fingerprint reader was connected.");
        }

        public void OnReaderDisconnect(object Capture, string ReaderSerialNumber)
        {
            MakeReport("The fingerprint reader was disconnected.");
        }

        public void OnSampleQuality(object Capture, string ReaderSerialNumber, DPFP.Capture.CaptureFeedback CaptureFeedback)
        {
            if (CaptureFeedback == DPFP.Capture.CaptureFeedback.Good)
                MakeReport("The quality of the fingerprint sample is good.");
            else
                MakeReport("The quality of the fingerprint sample is poor.");
        }
    #endregion

        protected Bitmap ConvertSampleToBitmap(DPFP.Sample Sample)
        {
            DPFP.Capture.SampleConversion Convertor = new DPFP.Capture.SampleConversion();  // Create a sample convertor.
            Bitmap bitmap = null;                                                           // TODO: the size doesn't matter
            Convertor.ConvertToPicture(Sample, ref bitmap);                                 // TODO: return bitmap as a result
            return bitmap;
        }

        protected DPFP.FeatureSet ExtractFeatures(DPFP.Sample Sample, DPFP.Processing.DataPurpose Purpose)
        {
            DPFP.Processing.FeatureExtraction Extractor = new DPFP.Processing.FeatureExtraction();  // Create a feature extractor
            DPFP.Capture.CaptureFeedback feedback = DPFP.Capture.CaptureFeedback.None;
            DPFP.FeatureSet features = new DPFP.FeatureSet();
            Extractor.CreateFeatureSet(Sample, Purpose, ref feedback, ref features);            // TODO: return features as a result?
            if (feedback == DPFP.Capture.CaptureFeedback.Good)
                return features;
            else
                return null;
        }

        protected void SetStatus(string status)
        {
            this.Invoke(
                new Function(delegate() {
                StatusLine.Text = status;
            }));
        }

        protected void SetPrompt(string prompt)
        {
            this.Invoke(new Function(delegate() {
                Prompt.Text = prompt;
            }));
        }
        protected void MakeReport(string message)
        {
            this.Invoke(new Function(delegate() {
                StatusText.AppendText(message + "\r\n");
            }));
        }

        private void DrawPicture(Bitmap bitmap)
        {
            this.Invoke(new Function(delegate() {
                Picture.Image = new Bitmap(bitmap, Picture.Size);   // fit the image into the picture box
            }));
        }

        private DPFP.Capture.Capture Capturer;

    }
}

And here is the Form the i'm working on.

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 System.IO;
using Enrollment;

//imports
using DHELTASSys.AuditTrail;


namespace DHELTASSys
{
    delegate void Function();

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        DHELTASSysAuditTrail daa = new DHELTASSysAuditTrail();

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtPrimaryNumber_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtCity_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtAlternativeNumber_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtSSSNumber_TextChanged_1(object sender, EventArgs e)
        {

        }

        private void txtPhilhealthNumber_TextChanged(object sender, EventArgs e)
        {

        }

        private void dtpBirthdate_ValueChanged(object sender, EventArgs e)
        {

        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            EnrollmentForm Enroller = new EnrollmentForm();
            Enroller.OnTemplate += this.OnTemplate;
            Enroller.ShowDialog();
        }

        private void OnTemplate(DPFP.Template template)
        {
            this.Invoke(new Function(delegate()
            {
                Template = template;
                btnSave.Enabled = (Template != null);
                if (Template != null)
                    MessageBox.Show("The fingerprint template is ready for saving.", "Fingerprint Enrollment");
                else
                    MessageBox.Show("The fingerprint template is not valid. Repeat fingerprint enrollment.", "Fingerprint Enrollment");
            }));

        }

        private DPFP.Template Template;

    }
}

I can't still find out how to solve this problem since I reviewed the sample codes given by Digital Persona, I can't still find where I did wrong.

protected void SetStatus(string status)
        {
            this.Invoke(
                new Function(delegate() {
                StatusLine.Text = status;
            }));
        }

This is the part that the error has pointed out. Not only that part but also all other declarations of the Function() Delegate in the CaptureForm.cs

Marcus Ang
  • 99
  • 1
  • 3
  • 10

1 Answers1

0

Your delegate is declared in a namespace that you aren't using. To fix this, you need to

  1. Make the delegate public
  2. add a using DHELTASSys; directive to the source file with the Enrollment namespace.
Ian McLaird
  • 5,507
  • 2
  • 22
  • 31