Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
I have this requirement in short from customer they have multiple biometric devices placed in 3-4 locations and sometime same user need to punchin on these different devices for access control or punchin requirements. Requirement is to synchronize user information and finger print template across devices.

Vendor has provided interop libraries which I am using to interface with device
they are
1. AxInterop.zkemkeeper.DLL
2. Interop.zkemkeeper.DLL.

But when you are creting a class from these libraries it demands to have
1. Gives error as ctivex interop assembly requires STAApartment which I did using thread giving it STA apartment from which I am calling method (Is it right to create thread under ASP.Net page, is it recommended)
2. It gives below error may be because activex interop library requires to embed itself under some container which is Windows Forms

System.Windows.Forms.AxHost.InvalidActiveXStateException was unhandled<br />
  Message=Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.<br />
  Source=AxInterop.zkemkeeper<br />
  StackTrace:<br />
       at Axzkemkeeper.AxCZKEM.Connect_Net(String iPAdd, Int32 port)<br />
       at WebApplication1._Default.Connect(AxCZKEM activeXagent, String strConnect, String cIP, Int32 cPort) in E:\Orwell\WindowsFormsApplication1\WebApplication1\Default.aspx.cs:line 101<br />
............................<br />
  InnerException: <br />

I m stuck at this point as I can not create a compatible container for this library if I try to embed it in web form it does not work.

---------------------------------------------------------------------------------------------------

I do have as an alternative First
1. Creating a web service which will be called from ASP or ASP.Net
2. Hosting this web service under a Windows service which will have windows forms project which will have these interop library calls executed this is because activex interop library requires to embed itself under some container which is Windows Forms.
3. Web service internally routing calls through windows service to this forms application/class.

I do have as an alternative Two
1. Keeping one in between table in which all needed information will be passed from ASP or ASP.Net
2. Creating a standalone application which poll this table to get the device calls to be made and will have these interop library calls executed within it this is because activex interop library requires to embed itself under some container which is Windows Forms.
3. Reporting back the outcome in table which will be taken by ASP/ASP.Net.

Do let me know your throughts on same as well.


Code pasted below
---------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Axzkemkeeper;
using zkemkeeper; 
using System.Configuration;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        string cIPFrom = "192.168.2.101";
        int cPortFrom = 4370;
        int gbMachineNumberFrom = 10;
        string gbEnrollNumberFrom = "12345";
        int gbFingerIndexFrom = 0;

        string cIPTo = "192.168.2.101";
        int cPortTo = 4370;
        int gbMachineNumberTo = 10;
        string gbEnrollNumberTo = "12345";
        int gbFingerIndexTo = 0;
        string gbTmpData = "";
        string strCommand = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            System.Threading.ThreadStart mtThreadStart = new System.Threading.ThreadStart(CallMeThread);
            //System.Action myAction = new Action(CallMeThread);
            System.Threading.Thread myThred = new System.Threading.Thread(mtThreadStart);
            //System.Threading.Thread(myAction);
            //myThred.RunSynchronously();   
            myThred.SetApartmentState(System.Threading.ApartmentState.STA);
            //myThred.Join();
            myThred.Start(); 
        }
        private void CallMeThread()
        {
               
            AxCZKEM activeXagent = new AxCZKEM();
            System.Windows.Forms.Form myForm = new System.Windows.Forms.Form();
            myForm.Controls.Add(activeXagent);  
 
            string gbResult = "";

            cIPFrom = Request["FromConnectIP"] == null ? "192.168.2.101" : Request["FromConnectIP"]; // ConfigurationSettings.AppSettings["ConnectIP"].ToString();
            cPortFrom = int.Parse(Request["FromConnectPort"] == null ? "4370" : Request["FromConnectPort"]); // int.Parse(ConfigurationSettings.AppSettings["ConnectPort"]);
            gbMachineNumberFrom = int.Parse(Request["FromMachineNumber"] == null ? "10" : Request["FromMachineNumber"]);//int.Parse(ConfigurationSettings.AppSettings["MachineNumber"]);
            gbEnrollNumberFrom = (Request["FromEnrollNumber"] == null ? "12345" : Request["FromEnrollNumber"]);
            gbFingerIndexFrom = int.Parse(Request["FromFingerIndex"] == null ? "0" : Request["FromFingerIndex"]);

            cIPTo = Request["ToConnectIP"] == null ? "192.168.2.101" : Request["ToConnectIP"]; // ConfigurationSettings.AppSettings["ConnectIP"].ToString();
            cPortTo = int.Parse(Request["ToConnectPort"] == null ? "4370" : Request["ToConnectPort"]); // int.Parse(ConfigurationSettings.AppSettings["ConnectPort"]);
            gbMachineNumberTo = int.Parse(Request["ToMachineNumber"] == null ? "10" : Request["ToMachineNumber"]);//int.Parse(ConfigurationSettings.AppSettings["MachineNumber"]);
            gbEnrollNumberTo = (Request["ToEnrollNumber"] == null ? "12345" : Request["ToEnrollNumber"]);
            gbFingerIndexTo = int.Parse(Request["ToFingerIndex"] == null ? "0" : Request["ToFingerIndex"]);

            gbTmpData = Request["TmpData"];
            strCommand = Request["DeviceCommand"] == "" ? "GetThumbnail" : Request["DeviceCommand"];
            switch (strCommand)
            {
                case "GetThumbnail":
                    Connect(activeXagent, "Connect", cIPFrom, cPortFrom);
                    gbTmpData = GetThumbNail(activeXagent, gbMachineNumberFrom, gbEnrollNumberFrom, gbFingerIndexFrom);
                    gbResult = "Thumbnail Retrieved From Device.." + gbEnrollNumberFrom;
                    Connect(activeXagent, "DisConnect", cIPFrom, cPortFrom);
                    break;
                //case "DelThumbnail":
                //    Connect("Connect",cIPFrom,cPortFrom);
                //    DelThumbnail(gbMachineNumberFrom, gbEnrollNumberFrom, gbFingerIndexFrom);
                //    gbResult = "Thumbnail Deleted From Device.. For" + gbEnrollNumberFrom;
                //    Connect("DisConnect",cIPFrom,cPortFrom);
                //    break;
                //case "SetThumbnail":
                //    Connect("Connect",cIPFrom,cPortFrom);
                //    SetThumbnail(gbMachineNumberTo, gbEnrollNumberTo, gbFingerIndexTo);
                //    gbResult = "Thumbnail Updated On Device.. For" + gbEnrollNumberFrom;
                //    Connect("DisConnect",cIPFrom,cPortFrom);
                //    break;
                //case "GetAndSetThumbnail":
                //    Connect("Connect",cIPFrom,cPortFrom);
                //    gbTmpData = GetThumbNail(gbMachineNumberFrom, gbEnrollNumberFrom, gbFingerIndexFrom);
                //    Connect("DisConnect",cIPFrom,cPortFrom);
                //    Connect("Connect",cIPTo,cPortTo);
                //    SetThumbnail(gbMachineNumberTo, gbEnrollNumberTo, gbFingerIndexTo, gbTmpData);   
                //    Connect("DisConnect",cIPTo,cPortTo);
                //    gbResult = "Thumbnail Updated From DeviceIP" + cIPFrom + " To Device" + cIPTo + " .. For" + gbEnrollNumberFrom;
                //    break;
            }
            idResult.Text = gbResult;
            //Response.Write gbResult;
        }
        private void Connect(AxCZKEM activeXagent, string strConnect, string cIP, int cPort)
        {
            bool boolResult = true;
            if (strConnect == "Connect")
            {
                boolResult = activeXagent.Connect_Net(cIP, cPort);
                if (boolResult)
                {
                }
            }
            else
            {
                activeXagent.Disconnect();
            }
        }
Posted
Updated 7-Jun-12 21:14pm
v2
Comments
Rajesh Anuhya 8-Jun-12 3:14am    
Edited
--RA
TNKumar 2-Jul-14 7:45am    
hi
can u please let me know the code to connect and read the stored data in bio-metric device..i am new to this i am able to do it in vb..but not able to get into asp.net web based application.

You do realize that ASP.NET code runs entirely on the web server, correct?

Are all of your biometric devices going to be attached directly to the web server?

This sounds as though you should NOT be writing a web site that does the authentication stuff with these devices.
 
Share this answer
 
Comments
Richard Deeming 13-Aug-15 15:00pm    
You do realise this is a question from 2012? :)

It only appeared in the list due to a spam-bot adding Solution #2.
Dave Kreskowiak 13-Aug-15 15:23pm    
Crap... sigh
Weird. The same guy put up Solution 1 too, 3 years ago.
C#
I have the same problem as you.Finally I Solved It.
Just at the last of your ThreadMethod Add "Application.Run();" It will OK.
please see:
<a href="http://www.codeproject.com/Questions/711973/Using-Zkemkeeper-dll-from-SDK-for-Biometric-scanne">Using Zkemkeeper dll from SDK  for Biometric scanner in Windows Service</a>[<a href="http://www.codeproject.com/Questions/711973/Using-Zkemkeeper-dll-from-SDK-for-Biometric-scanne" target="_blank" title="New Window">^</a>]
 
Share this answer
 
Interop.zkemkeeper.dll
CSS
regsvr32 error or InitializeComponent
Then you need done the step following:
1. Go to webiste: http://www.zktechnology.com
2. Download ->Software Download->ZK Access for C3 panels
3. Extract files
4. Install
5. Open visual studio -> Solution Project->references-> Add Interop.zkemkeeper.dll
Good luck
If successfully then you visit website of me http://phuphat.com or http://thoigianso.com to hepl direct hihi
 
Share this answer
 
Comments
Member 10379057 11-Mar-15 2:21am    
OnFinger Event of zkeemkeeper is not wrking or trigger when finger is pressed in asp.net ?
You can using file AxInterop.zkemkeeper.dll follow link http://phuphat.vn/images/SharePackageInstall/AxInterop.zkemkeeper.dll
after you register, i think it help you
 
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