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

Pinvoke help

the LeafProject http://www.leafproject.org has a DLL for Face
recognition. it is written in C++ but they interface to it from Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.

;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")

; an interface function:
; -1 = ERROR: camera failed to start
; 0 = camera on successfully
(fli:define-foreign-function
(Start-Camera "StartCamera")
()
:result-type :int)

; an interface function:
; -1 = ERROR: camera failed to stop
; 0 = camera off successfully
(fli:define-foreign-function
(Stop-Camera "StopCamera")
()
:result-type :int)

; an interface function:
; returns the number of face images in the database
(fli:define-foreign-function
(Get-Number-Images "GetNum")
()
:result-type :int)

; an interface function:
; -2 = ERROR: write error
; -1 = ERROR: could not create values.txt file
; 0 = eigens created and stored successfully
(fli:define-foreign-function
(Calc-Eigens "DoEigen")
()
:result-type :int)

; an interface function
; -1 = ERROR: could not rename or add face
; 0 = face added sucessfully
(fli:define-foreign-function
(Add-Face "AddFace")
()
:result-type :int)

; an interface function
; -4 = ERROR: could not save face image
; -3 = ERROR: could not read coefficient file
; -2 = ERROR: could not capture
; -1 = ERROR: could not load classifier cascade
; 0 or more = number of faces detected... if only one face detected,
then
; return string = image number as a string, eg. "6" means image 6
(fli:define-foreign-function
(Look-For-Faces "LookForFaces")
((return-string (:reference-return (:ef-mb-string :limit 256))))
:result-type :int
:lambda-list (&aux return-string)
:language :c
:calling-convention :cdecl
:result-type :int)

So from that I looked up Pinvoke and wrote this code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FaceRecognition
{
public partial class Form1 : Form
{
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
[DllImport("FaceRecog.dll")]
public static extern int GetNum();
[DllImport("FaceRecog.dll")]
public static extern int DoEigen();
[DllImport("FaceRecog.dll")]
public static extern int AddFace();
[DllImport("FaceRecog.dll")]
public static extern int LookForFaces();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
int result = StartCamera();
Console.WriteLine(" startcamera = " + result);
}
}
}

When I click the button to do StartCamera I get the following message
like it cannot find the DLL (which is in windows/system32). I have
tried moving the DLL to the C# apps directory too but that did not
help either. What am I doing wrong?

Thanks
Ringo
System.DllNotFoundException was unhandled
Message="Unable to load DLL 'facerecog.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
Source="FaceRecognition"
TypeName=""
StackTrace:
at FaceRecognition.Form1.StartCamera()
at FaceRecognition.Form1.button1_Click(Object sender, EventArgs
e) in E:\FaceRecognition\FaceRecognition\Form1.cs:line 78
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FaceRecognition.Program.Main() in e:\FaceRecognition
\FaceRecognition\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

May 7 '07 #1
9 2700
Can you show the header file for C++ to access this? You woud probably
have more people able to help if you provided that, and it would be easier
to show you the declarations you would need.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ringo" <ri*********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
the LeafProject http://www.leafproject.org has a DLL for Face
recognition. it is written in C++ but they interface to it from Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.

;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")

; an interface function:
; -1 = ERROR: camera failed to start
; 0 = camera on successfully
(fli:define-foreign-function
(Start-Camera "StartCamera")
()
:result-type :int)

; an interface function:
; -1 = ERROR: camera failed to stop
; 0 = camera off successfully
(fli:define-foreign-function
(Stop-Camera "StopCamera")
()
:result-type :int)

; an interface function:
; returns the number of face images in the database
(fli:define-foreign-function
(Get-Number-Images "GetNum")
()
:result-type :int)

; an interface function:
; -2 = ERROR: write error
; -1 = ERROR: could not create values.txt file
; 0 = eigens created and stored successfully
(fli:define-foreign-function
(Calc-Eigens "DoEigen")
()
:result-type :int)

; an interface function
; -1 = ERROR: could not rename or add face
; 0 = face added sucessfully
(fli:define-foreign-function
(Add-Face "AddFace")
()
:result-type :int)

; an interface function
; -4 = ERROR: could not save face image
; -3 = ERROR: could not read coefficient file
; -2 = ERROR: could not capture
; -1 = ERROR: could not load classifier cascade
; 0 or more = number of faces detected... if only one face detected,
then
; return string = image number as a string, eg. "6" means image 6
(fli:define-foreign-function
(Look-For-Faces "LookForFaces")
((return-string (:reference-return (:ef-mb-string :limit 256))))
:result-type :int
:lambda-list (&aux return-string)
:language :c
:calling-convention :cdecl
:result-type :int)

So from that I looked up Pinvoke and wrote this code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FaceRecognition
{
public partial class Form1 : Form
{
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
[DllImport("FaceRecog.dll")]
public static extern int GetNum();
[DllImport("FaceRecog.dll")]
public static extern int DoEigen();
[DllImport("FaceRecog.dll")]
public static extern int AddFace();
[DllImport("FaceRecog.dll")]
public static extern int LookForFaces();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
int result = StartCamera();
Console.WriteLine(" startcamera = " + result);
}
}
}

When I click the button to do StartCamera I get the following message
like it cannot find the DLL (which is in windows/system32). I have
tried moving the DLL to the C# apps directory too but that did not
help either. What am I doing wrong?

Thanks
Ringo
System.DllNotFoundException was unhandled
Message="Unable to load DLL 'facerecog.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
Source="FaceRecognition"
TypeName=""
StackTrace:
at FaceRecognition.Form1.StartCamera()
at FaceRecognition.Form1.button1_Click(Object sender, EventArgs
e) in E:\FaceRecognition\FaceRecognition\Form1.cs:line 78
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FaceRecognition.Program.Main() in e:\FaceRecognition
\FaceRecognition\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

May 7 '07 #2
I jsut got the .H file used. i was going by the LISP code. I'm not a C+
+ guy at all, but I don't see anything in the .H file that has to do
with the function names called. Am I missing somethign here?
// FaceRecog.h : main header file for the FACERECOG DLL
//

#if !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)
#define
AFX_FACERECOG_H__484912E7_8723_407A_91D6_39A24AD3B 3E4__INCLUDED_

#if _MSC_VER 1000
#pragma once
#endif // _MSC_VER 1000

#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h" // main symbols

/////////////////////////////////////////////////////////////////////////////
// CFaceRecogApp
// See FaceRecog.cpp for the implementation of this class
//

class CFaceRecogApp : public CWinApp
{
public:
CFaceRecogApp();

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFaceRecogApp)
public:
//}}AFX_VIRTUAL

//{{AFX_MSG(CFaceRecogApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations
immediately before the previous line.

#endif // !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)
On May 7, 1:20 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Can you show the header file for C++ to access this? You woud probably
have more people able to help if you provided that, and it would be easier
to show you the declarations you would need.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Ringo" <ringo.da...@gmail.comwrote in message

news:11**********************@n59g2000hsh.googlegr oups.com...
the LeafProjecthttp://www.leafproject.orghas a DLL for Face
recognition. it is written in C++ but they interface to it from Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.
;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")
; an interface function:
; -1 = ERROR: camera failed to start
; 0 = camera on successfully
(fli:define-foreign-function
(Start-Camera "StartCamera")
()
:result-type :int)
; an interface function:
; -1 = ERROR: camera failed to stop
; 0 = camera off successfully
(fli:define-foreign-function
(Stop-Camera "StopCamera")
()
:result-type :int)
; an interface function:
; returns the number of face images in the database
(fli:define-foreign-function
(Get-Number-Images "GetNum")
()
:result-type :int)
; an interface function:
; -2 = ERROR: write error
; -1 = ERROR: could not create values.txt file
; 0 = eigens created and stored successfully
(fli:define-foreign-function
(Calc-Eigens "DoEigen")
()
:result-type :int)
; an interface function
; -1 = ERROR: could not rename or add face
; 0 = face added sucessfully
(fli:define-foreign-function
(Add-Face "AddFace")
()
:result-type :int)
; an interface function
; -4 = ERROR: could not save face image
; -3 = ERROR: could not read coefficient file
; -2 = ERROR: could not capture
; -1 = ERROR: could not load classifier cascade
; 0 or more = number of faces detected... if only one face detected,
then
; return string = image number as a string, eg. "6" means image 6
(fli:define-foreign-function
(Look-For-Faces "LookForFaces")
((return-string (:reference-return (:ef-mb-string :limit 256))))
:result-type :int
:lambda-list (&aux return-string)
:language :c
:calling-convention :cdecl
:result-type :int)
So from that I looked up Pinvoke and wrote this code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FaceRecognition
{
public partial class Form1 : Form
{
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
[DllImport("FaceRecog.dll")]
public static extern int GetNum();
[DllImport("FaceRecog.dll")]
public static extern int DoEigen();
[DllImport("FaceRecog.dll")]
public static extern int AddFace();
[DllImport("FaceRecog.dll")]
public static extern int LookForFaces();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int result = StartCamera();
Console.WriteLine(" startcamera = " + result);
}
}
}
When I click the button to do StartCamera I get the following message
like it cannot find the DLL (which is in windows/system32). I have
tried moving the DLL to the C# apps directory too but that did not
help either. What am I doing wrong?
Thanks
Ringo
System.DllNotFoundException was unhandled
Message="Unable to load DLL 'facerecog.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
Source="FaceRecognition"
TypeName=""
StackTrace:
at FaceRecognition.Form1.StartCamera()
at FaceRecognition.Form1.button1_Click(Object sender, EventArgs
e) in E:\FaceRecognition\FaceRecognition\Form1.cs:line 78
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.Unsa*feNativeMethods.IMsoComp onentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FaceRecognition.Program.Main() in e:\FaceRecognition
\FaceRecognition\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()- Hide quoted text -

- Show quoted text -

May 7 '07 #3
On May 7, 1:29 pm, Ringo <ringo.da...@gmail.comwrote:
I jsut got the .H file used. i was going by the LISP code. I'm not a C+
+ guy at all, but I don't see anything in the .H file that has to do
with the function names called. Am I missing somethign here?

// FaceRecog.h : main header file for the FACERECOG DLL
//

#if !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)
#define
AFX_FACERECOG_H__484912E7_8723_407A_91D6_39A24AD3B 3E4__INCLUDED_

#if _MSC_VER 1000
#pragma once
#endif // _MSC_VER 1000

#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h" // main symbols

///////////////////////////////////////////////////////////////////////////*//
// CFaceRecogApp
// See FaceRecog.cpp for the implementation of this class
//

class CFaceRecogApp : public CWinApp
{
public:
CFaceRecogApp();

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFaceRecogApp)
public:
//}}AFX_VIRTUAL

//{{AFX_MSG(CFaceRecogApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

};

///////////////////////////////////////////////////////////////////////////*//

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations
immediately before the previous line.

#endif // !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)

On May 7, 1:20 pm, "Nicholas Paldino [.NET/C# MVP]"

<m...@spam.guard.caspershouse.comwrote:
Can you show the header file for C++ to access this? You woud probably
have more people able to help if you provided that, and it would be easier
to show you the declarations you would need.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Ringo" <ringo.da...@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
the LeafProjecthttp://www.leafproject.orghasa DLL for Face
recognition. it is written in C++ but they interface to it from Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.
;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")
; an interface function:
; -1 = ERROR: camera failed to start
; 0 = camera on successfully
(fli:define-foreign-function
(Start-Camera "StartCamera")
()
:result-type :int)
; an interface function:
; -1 = ERROR: camera failed to stop
; 0 = camera off successfully
(fli:define-foreign-function
(Stop-Camera "StopCamera")
()
:result-type :int)
; an interface function:
; returns the number of face images in the database
(fli:define-foreign-function
(Get-Number-Images "GetNum")
()
:result-type :int)
; an interface function:
; -2 = ERROR: write error
; -1 = ERROR: could not create values.txt file
; 0 = eigens created and stored successfully
(fli:define-foreign-function
(Calc-Eigens "DoEigen")
()
:result-type :int)
; an interface function
; -1 = ERROR: could not rename or add face
; 0 = face added sucessfully
(fli:define-foreign-function
(Add-Face "AddFace")
()
:result-type :int)
; an interface function
; -4 = ERROR: could not save face image
; -3 = ERROR: could not read coefficient file
; -2 = ERROR: could not capture
; -1 = ERROR: could not load classifier cascade
; 0 or more = number of faces detected... if only one face detected,
then
; return string = image number as a string, eg. "6" means image 6
(fli:define-foreign-function
(Look-For-Faces "LookForFaces")
((return-string (:reference-return (:ef-mb-string :limit 256))))
:result-type :int
:lambda-list (&aux return-string)
:language :c
:calling-convention :cdecl
:result-type :int)
So from that I looked up Pinvoke and wrote this code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FaceRecognition
{
public partial class Form1 : Form
{
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
[DllImport("FaceRecog.dll")]
public static extern int GetNum();
[DllImport("FaceRecog.dll")]
public static extern int DoEigen();
[DllImport("FaceRecog.dll")]
public static extern int AddFace();
[DllImport("FaceRecog.dll")]
public static extern int LookForFaces();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int result = StartCamera();
Console.WriteLine(" startcamera = " + result);
}
}
}
When I click the button to do StartCamera I get the following message
like it cannot find the DLL (which is in windows/system32). I have
tried moving the DLL to the C# apps directory too but that did not
help either. What am I doing wrong?
Thanks
Ringo
System.DllNotFoundException was unhandled
Message="Unable to load DLL 'facerecog.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
Source="FaceRecognition"
TypeName=""
StackTrace:
at FaceRecognition.Form1.StartCamera()
at FaceRecognition.Form1.button1_Click(Object sender, EventArgs
e) in E:\FaceRecognition\FaceRecognition\Form1.cs:line 78
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.Unsa**feNativeMethods.IMsoCom ponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FaceRecognition.Program.Main() in e:\FaceRecognition
\FaceRecognition\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Also here are the definitions at the begginning of the .cpp file
extern "C" __declspec(dllexport) int GetNum();
extern "C" __declspec(dllexport) int DoEigen();
extern "C" __declspec(dllexport) int LookForFaces(char* place);
extern "C" __declspec(dllexport) int AddFace();
extern "C" __declspec(dllexport) int StartCamera();
extern "C" __declspec(dllexport) int StopCamera();

May 7 '07 #4
Hi Ringo

I don't know for sure if the argument to the DllImportAttribute is case
sensitive or not, but I notice that the first one is in lower case in
your code:
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();

Ringo wrote:
the LeafProject http://www.leafproject.org has a DLL for Face
recognition. it is written in C++ but they interface to it from Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.

;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")

; an interface function:
; -1 = ERROR: camera failed to start
; 0 = camera on successfully
(fli:define-foreign-function
(Start-Camera "StartCamera")
()
:result-type :int)

; an interface function:
; -1 = ERROR: camera failed to stop
; 0 = camera off successfully
(fli:define-foreign-function
(Stop-Camera "StopCamera")
()
:result-type :int)

; an interface function:
; returns the number of face images in the database
(fli:define-foreign-function
(Get-Number-Images "GetNum")
()
:result-type :int)

; an interface function:
; -2 = ERROR: write error
; -1 = ERROR: could not create values.txt file
; 0 = eigens created and stored successfully
(fli:define-foreign-function
(Calc-Eigens "DoEigen")
()
:result-type :int)

; an interface function
; -1 = ERROR: could not rename or add face
; 0 = face added sucessfully
(fli:define-foreign-function
(Add-Face "AddFace")
()
:result-type :int)

; an interface function
; -4 = ERROR: could not save face image
; -3 = ERROR: could not read coefficient file
; -2 = ERROR: could not capture
; -1 = ERROR: could not load classifier cascade
; 0 or more = number of faces detected... if only one face detected,
then
; return string = image number as a string, eg. "6" means image 6
(fli:define-foreign-function
(Look-For-Faces "LookForFaces")
((return-string (:reference-return (:ef-mb-string :limit 256))))
:result-type :int
:lambda-list (&aux return-string)
:language :c
:calling-convention :cdecl
:result-type :int)

So from that I looked up Pinvoke and wrote this code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FaceRecognition
{
public partial class Form1 : Form
{
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
[DllImport("FaceRecog.dll")]
public static extern int GetNum();
[DllImport("FaceRecog.dll")]
public static extern int DoEigen();
[DllImport("FaceRecog.dll")]
public static extern int AddFace();
[DllImport("FaceRecog.dll")]
public static extern int LookForFaces();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
int result = StartCamera();
Console.WriteLine(" startcamera = " + result);
}
}
}

When I click the button to do StartCamera I get the following message
like it cannot find the DLL (which is in windows/system32). I have
tried moving the DLL to the C# apps directory too but that did not
help either. What am I doing wrong?

Thanks
Ringo
System.DllNotFoundException was unhandled
Message="Unable to load DLL 'facerecog.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
Source="FaceRecognition"
TypeName=""
StackTrace:
at FaceRecognition.Form1.StartCamera()
at FaceRecognition.Form1.button1_Click(Object sender, EventArgs
e) in E:\FaceRecognition\FaceRecognition\Form1.cs:line 78
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FaceRecognition.Program.Main() in e:\FaceRecognition
\FaceRecognition\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
May 7 '07 #5
On May 7, 2:15 pm, Dave Shooter
<alwayskeepitloaded@delete_this.googlemail.comwrot e:
Hi Ringo

I don't know for sure if the argument to the DllImportAttribute is case
sensitive or not, but I notice that the first one is in lower case in
your code:
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
Ringo wrote:
the LeafProjecthttp://www.leafproject.orghas a DLL for Face
recognition. it is written in C++ but they interface to it from Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.
;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")
; an interface function:
; -1 = ERROR: camera failed to start
; 0 = camera on successfully
(fli:define-foreign-function
(Start-Camera "StartCamera")
()
:result-type :int)
; an interface function:
; -1 = ERROR: camera failed to stop
; 0 = camera off successfully
(fli:define-foreign-function
(Stop-Camera "StopCamera")
()
:result-type :int)
; an interface function:
; returns the number of face images in the database
(fli:define-foreign-function
(Get-Number-Images "GetNum")
()
:result-type :int)
; an interface function:
; -2 = ERROR: write error
; -1 = ERROR: could not create values.txt file
; 0 = eigens created and stored successfully
(fli:define-foreign-function
(Calc-Eigens "DoEigen")
()
:result-type :int)
; an interface function
; -1 = ERROR: could not rename or add face
; 0 = face added sucessfully
(fli:define-foreign-function
(Add-Face "AddFace")
()
:result-type :int)
; an interface function
; -4 = ERROR: could not save face image
; -3 = ERROR: could not read coefficient file
; -2 = ERROR: could not capture
; -1 = ERROR: could not load classifier cascade
; 0 or more = number of faces detected... if only one face detected,
then
; return string = image number as a string, eg. "6" means image 6
(fli:define-foreign-function
(Look-For-Faces "LookForFaces")
((return-string (:reference-return (:ef-mb-string :limit 256))))
:result-type :int
:lambda-list (&aux return-string)
:language :c
:calling-convention :cdecl
:result-type :int)
So from that I looked up Pinvoke and wrote this code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FaceRecognition
{
public partial class Form1 : Form
{
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
[DllImport("FaceRecog.dll")]
public static extern int GetNum();
[DllImport("FaceRecog.dll")]
public static extern int DoEigen();
[DllImport("FaceRecog.dll")]
public static extern int AddFace();
[DllImport("FaceRecog.dll")]
public static extern int LookForFaces();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int result = StartCamera();
Console.WriteLine(" startcamera = " + result);
}
}
}
When I click the button to do StartCamera I get the following message
like it cannot find the DLL (which is in windows/system32). I have
tried moving the DLL to the C# apps directory too but that did not
help either. What am I doing wrong?
Thanks
Ringo
System.DllNotFoundException was unhandled
Message="Unable to load DLL 'facerecog.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
Source="FaceRecognition"
TypeName=""
StackTrace:
at FaceRecognition.Form1.StartCamera()
at FaceRecognition.Form1.button1_Click(Object sender, EventArgs
e) in E:\FaceRecognition\FaceRecognition\Form1.cs:line 78
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.Unsa*feNativeMethods.IMsoComp onentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FaceRecognition.Program.Main() in e:\FaceRecognition
\FaceRecognition\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()- Hide quoted text-

- Show quoted text -
I've tried uppercase, lowercase, etc. I copied the name of the file
directly from the file itself and pasted that to be sure and still get
the same error. I have commented out all the other pinvokes except the
start camera and it still crashes. Must be something I'm missing. any
other ideas?
Ringo

May 7 '07 #6
Have you tried hard-coding the path to the dll just to see if it works?
Also, is the facerecog.dll stand-alone? If so, place it in the same
directory as your application and it should work.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ringo" <ri*********@gmail.comwrote in message
news:11**********************@h2g2000hsg.googlegro ups.com...
On May 7, 1:29 pm, Ringo <ringo.da...@gmail.comwrote:
I jsut got the .H file used. i was going by the LISP code. I'm not a C+
+ guy at all, but I don't see anything in the .H file that has to do
with the function names called. Am I missing somethign here?

// FaceRecog.h : main header file for the FACERECOG DLL
//

#if !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)
#define
AFX_FACERECOG_H__484912E7_8723_407A_91D6_39A24AD3B 3E4__INCLUDED_

#if _MSC_VER 1000
#pragma once
#endif // _MSC_VER 1000

#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h" // main symbols

///////////////////////////////////////////////////////////////////////////*//
// CFaceRecogApp
// See FaceRecog.cpp for the implementation of this class
//

class CFaceRecogApp : public CWinApp
{
public:
CFaceRecogApp();

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFaceRecogApp)
public:
//}}AFX_VIRTUAL

//{{AFX_MSG(CFaceRecogApp)
// NOTE - the ClassWizard will add and remove member
functions here.
// DO NOT EDIT what you see in these blocks of
generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

};

///////////////////////////////////////////////////////////////////////////*//

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations
immediately before the previous line.

#endif // !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)

On May 7, 1:20 pm, "Nicholas Paldino [.NET/C# MVP]"

<m...@spam.guard.caspershouse.comwrote:
Can you show the header file for C++ to access this? You woud
probably
have more people able to help if you provided that, and it would be
easier
to show you the declarations you would need.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Ringo" <ringo.da...@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
the LeafProjecthttp://www.leafproject.orghasa DLL for Face
recognition. it is written in C++ but they interface to it from Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.
;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")
; an interface function:
; -1 = ERROR: camera failed to start
; 0 = camera on successfully
(fli:define-foreign-function
(Start-Camera "StartCamera")
()
:result-type :int)
; an interface function:
; -1 = ERROR: camera failed to stop
; 0 = camera off successfully
(fli:define-foreign-function
(Stop-Camera "StopCamera")
()
:result-type :int)
; an interface function:
; returns the number of face images in the database
(fli:define-foreign-function
(Get-Number-Images "GetNum")
()
:result-type :int)
; an interface function:
; -2 = ERROR: write error
; -1 = ERROR: could not create values.txt file
; 0 = eigens created and stored successfully
(fli:define-foreign-function
(Calc-Eigens "DoEigen")
()
:result-type :int)
; an interface function
; -1 = ERROR: could not rename or add face
; 0 = face added sucessfully
(fli:define-foreign-function
(Add-Face "AddFace")
()
:result-type :int)
; an interface function
; -4 = ERROR: could not save face image
; -3 = ERROR: could not read coefficient file
; -2 = ERROR: could not capture
; -1 = ERROR: could not load classifier cascade
; 0 or more = number of faces detected... if only one face detected,
then
; return string = image number as a string, eg. "6" means image 6
(fli:define-foreign-function
(Look-For-Faces "LookForFaces")
((return-string (:reference-return (:ef-mb-string :limit 256))))
:result-type :int
:lambda-list (&aux return-string)
:language :c
:calling-convention :cdecl
:result-type :int)
So from that I looked up Pinvoke and wrote this code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FaceRecognition
{
public partial class Form1 : Form
{
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
[DllImport("FaceRecog.dll")]
public static extern int GetNum();
[DllImport("FaceRecog.dll")]
public static extern int DoEigen();
[DllImport("FaceRecog.dll")]
public static extern int AddFace();
[DllImport("FaceRecog.dll")]
public static extern int LookForFaces();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int result = StartCamera();
Console.WriteLine(" startcamera = " + result);
}
}
}
When I click the button to do StartCamera I get the following message
like it cannot find the DLL (which is in windows/system32). I have
tried moving the DLL to the C# apps directory too but that did not
help either. What am I doing wrong?
Thanks
Ringo
System.DllNotFoundException was unhandled
Message="Unable to load DLL 'facerecog.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
Source="FaceRecognition"
TypeName=""
StackTrace:
at FaceRecognition.Form1.StartCamera()
at FaceRecognition.Form1.button1_Click(Object sender, EventArgs
e) in E:\FaceRecognition\FaceRecognition\Form1.cs:line 78
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.Unsa**feNativeMethods.IMsoCom ponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FaceRecognition.Program.Main() in e:\FaceRecognition
\FaceRecognition\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()- Hide quoted
text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Also here are the definitions at the begginning of the .cpp file
extern "C" __declspec(dllexport) int GetNum();
extern "C" __declspec(dllexport) int DoEigen();
extern "C" __declspec(dllexport) int LookForFaces(char* place);
extern "C" __declspec(dllexport) int AddFace();
extern "C" __declspec(dllexport) int StartCamera();
extern "C" __declspec(dllexport) int StopCamera();
May 7 '07 #7
I've tried somethign like
[DllImport("c:\Windows\system32\FaceRecog.dll")]
public static extern int StartCamera();

But it did not like the "\"'s.

I also tried putting the dll where the .sln file goes and down 1
directory where the rest of the files go and got the same result.
still no luck.

On May 7, 2:39 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Have you tried hard-coding the path to the dll just to see if it works?
Also, is the facerecog.dll stand-alone? If so, place it in the same
directory as your application and it should work.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Ringo" <ringo.da...@gmail.comwrote in message

news:11**********************@h2g2000hsg.googlegro ups.com...
On May 7, 1:29 pm, Ringo <ringo.da...@gmail.comwrote:


I jsut got the .H file used. i was going by the LISP code. I'm not a C+
+ guy at all, but I don't see anything in the .H file that has to do
with the function names called. Am I missing somethign here?
// FaceRecog.h : main header file for the FACERECOG DLL
//
#if !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)
#define
AFX_FACERECOG_H__484912E7_8723_407A_91D6_39A24AD3B 3E4__INCLUDED_
#if _MSC_VER 1000
#pragma once
#endif // _MSC_VER 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
///////////////////////////////////////////////////////////////////////////**//
// CFaceRecogApp
// See FaceRecog.cpp for the implementation of this class
//
class CFaceRecogApp : public CWinApp
{
public:
CFaceRecogApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFaceRecogApp)
public:
//}}AFX_VIRTUAL
//{{AFX_MSG(CFaceRecogApp)
// NOTE - the ClassWizard will add and remove member
functions here.
// DO NOT EDIT what you see in these blocks of
generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
///////////////////////////////////////////////////////////////////////////**//
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations
immediately before the previous line.
#endif // !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)
On May 7, 1:20 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Can you show the header file for C++ to access this? You woud
probably
have more people able to help if you provided that, and it would be
easier
to show you the declarations you would need.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Ringo" <ringo.da...@gmail.comwrote in message
>news:11**********************@n59g2000hsh.googleg roups.com...
the LeafProjecthttp://www.leafproject.orghasaDLL for Face
recognition. it is written in C++ but they interface to it from Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.
;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")
; an interface function:
; -1 = ERROR: camera failed to start
; 0 = camera on successfully
(fli:define-foreign-function
(Start-Camera "StartCamera")
()
:result-type :int)
; an interface function:
; -1 = ERROR: camera failed to stop
; 0 = camera off successfully
(fli:define-foreign-function
(Stop-Camera "StopCamera")
()
:result-type :int)
; an interface function:
; returns the number of face images in the database
(fli:define-foreign-function
(Get-Number-Images "GetNum")
()
:result-type :int)
; an interface function:
; -2 = ERROR: write error
; -1 = ERROR: could not create values.txt file
; 0 = eigens created and stored successfully
(fli:define-foreign-function
(Calc-Eigens "DoEigen")
()
:result-type :int)
; an interface function
; -1 = ERROR: could not rename or add face
; 0 = face added sucessfully
(fli:define-foreign-function
(Add-Face "AddFace")
()
:result-type :int)
; an interface function
; -4 = ERROR: could not save face image
; -3 = ERROR: could not read coefficient file
; -2 = ERROR: could not capture
; -1 = ERROR: could not load classifier cascade
; 0 or more = number of faces detected... if only one face detected,
then
; return string = image number as a string, eg. "6" means image 6
(fli:define-foreign-function
(Look-For-Faces "LookForFaces")
((return-string (:reference-return (:ef-mb-string :limit 256))))
:result-type :int
:lambda-list (&aux return-string)
:language :c
:calling-convention :cdecl
:result-type :int)
So from that I looked up Pinvoke and wrote this code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FaceRecognition
{
public partial class Form1 : Form
{
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
[DllImport("FaceRecog.dll")]
public static extern int GetNum();
[DllImport("FaceRecog.dll")]
public static extern int DoEigen();
[DllImport("FaceRecog.dll")]
public static extern int AddFace();
[DllImport("FaceRecog.dll")]
public static extern int LookForFaces();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int result = StartCamera();
Console.WriteLine(" startcamera = " + result);
}
}
}
When I click the button to do StartCamera I get the following message
like it cannot find the DLL (which is in windows/system32). I have
tried moving the DLL to the C# apps directory too but that did not
help either. What am I doing wrong?
Thanks
Ringo
System.DllNotFoundException was unhandled
Message="Unable to load DLL 'facerecog.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
Source="FaceRecognition"
TypeName=""
StackTrace:
at FaceRecognition.Form1.StartCamera()
at FaceRecognition.Form1.button1_Click(Object sender, EventArgs
e) in E:\FaceRecognition\FaceRecognition\Form1.cs:line 78
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message&m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.Unsa***feNativeMethods.IMsoCo mponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FaceRecognition.Program.Main() in e:\FaceRecognition
\FaceRecognition\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()- Hide quoted
text -
- Show quoted text -- Hide quoted text -
- Show quoted text -

Also here are the definitions at the begginning of the .cpp file
extern "C" __declspec(dllexport) int GetNum();
extern "C" __declspec(dllexport) int DoEigen();
extern "C" __declspec(dllexport) int LookForFaces(char* place);
extern "C" __declspec(dllexport) int AddFace();
extern "C" __declspec(dllexport) int StartCamera();
extern "C" __declspec(dllexport) int StopCamera();- Hide quoted text -

- Show quoted text -

May 7 '07 #8
Ringo,

If the path to the DLL is this:

"c:\Windows\system32\FaceRecog.dll"

Then your DllImport needs to be this:

[DllImport(@"c:\Windows\system32\FaceRecog.dll")]

Or this:
[DllImport("c:\\Windows\\system32\\FaceRecog.dll")]

Also, you say you put the dll one directory down from where the .sln
file is, which would be the project directory, but that isn't where the
output EXE is built. Place it in that directory and see if it works without
the full path.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ringo" <ri*********@gmail.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
I've tried somethign like
[DllImport("c:\Windows\system32\FaceRecog.dll")]
public static extern int StartCamera();

But it did not like the "\"'s.

I also tried putting the dll where the .sln file goes and down 1
directory where the rest of the files go and got the same result.
still no luck.

On May 7, 2:39 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Have you tried hard-coding the path to the dll just to see if it
works?
Also, is the facerecog.dll stand-alone? If so, place it in the same
directory as your application and it should work.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Ringo" <ringo.da...@gmail.comwrote in message

news:11**********************@h2g2000hsg.googlegro ups.com...
On May 7, 1:29 pm, Ringo <ringo.da...@gmail.comwrote:


I jsut got the .H file used. i was going by the LISP code. I'm not a C+
+ guy at all, but I don't see anything in the .H file that has to do
with the function names called. Am I missing somethign here?
// FaceRecog.h : main header file for the FACERECOG DLL
//
#if !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)
#define
AFX_FACERECOG_H__484912E7_8723_407A_91D6_39A24AD3B 3E4__INCLUDED_
#if _MSC_VER 1000
#pragma once
#endif // _MSC_VER 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
///////////////////////////////////////////////////////////////////////////**//
// CFaceRecogApp
// See FaceRecog.cpp for the implementation of this class
//
class CFaceRecogApp : public CWinApp
{
public:
CFaceRecogApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFaceRecogApp)
public:
//}}AFX_VIRTUAL
//{{AFX_MSG(CFaceRecogApp)
// NOTE - the ClassWizard will add and remove member
functions here.
// DO NOT EDIT what you see in these blocks of
generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
///////////////////////////////////////////////////////////////////////////**//
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations
immediately before the previous line.
#endif // !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)
On May 7, 1:20 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Can you show the header file for C++ to access this? You woud
probably
have more people able to help if you provided that, and it would be
easier
to show you the declarations you would need.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Ringo" <ringo.da...@gmail.comwrote in message
>news:11**********************@n59g2000hsh.googleg roups.com...
the LeafProjecthttp://www.leafproject.orghasaDLL for Face
recognition. it is written in C++ but they interface to it from
Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.
;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")
; an interface function:
; -1 = ERROR: camera failed to start
; 0 = camera on successfully
(fli:define-foreign-function
(Start-Camera "StartCamera")
()
:result-type :int)
; an interface function:
; -1 = ERROR: camera failed to stop
; 0 = camera off successfully
(fli:define-foreign-function
(Stop-Camera "StopCamera")
()
:result-type :int)
; an interface function:
; returns the number of face images in the database
(fli:define-foreign-function
(Get-Number-Images "GetNum")
()
:result-type :int)
; an interface function:
; -2 = ERROR: write error
; -1 = ERROR: could not create values.txt file
; 0 = eigens created and stored successfully
(fli:define-foreign-function
(Calc-Eigens "DoEigen")
()
:result-type :int)
; an interface function
; -1 = ERROR: could not rename or add face
; 0 = face added sucessfully
(fli:define-foreign-function
(Add-Face "AddFace")
()
:result-type :int)
; an interface function
; -4 = ERROR: could not save face image
; -3 = ERROR: could not read coefficient file
; -2 = ERROR: could not capture
; -1 = ERROR: could not load classifier cascade
; 0 or more = number of faces detected... if only one face
detected,
then
; return string = image number as a string, eg. "6" means image 6
(fli:define-foreign-function
(Look-For-Faces "LookForFaces")
((return-string (:reference-return (:ef-mb-string :limit 256))))
:result-type :int
:lambda-list (&aux return-string)
:language :c
:calling-convention :cdecl
:result-type :int)
So from that I looked up Pinvoke and wrote this code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FaceRecognition
{
public partial class Form1 : Form
{
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
[DllImport("FaceRecog.dll")]
public static extern int GetNum();
[DllImport("FaceRecog.dll")]
public static extern int DoEigen();
[DllImport("FaceRecog.dll")]
public static extern int AddFace();
[DllImport("FaceRecog.dll")]
public static extern int LookForFaces();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int result = StartCamera();
Console.WriteLine(" startcamera = " + result);
}
}
}
When I click the button to do StartCamera I get the following
message
like it cannot find the DLL (which is in windows/system32). I have
tried moving the DLL to the C# apps directory too but that did not
help either. What am I doing wrong?
Thanks
Ringo
System.DllNotFoundException was unhandled
Message="Unable to load DLL 'facerecog.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
Source="FaceRecognition"
TypeName=""
StackTrace:
at FaceRecognition.Form1.StartCamera()
at FaceRecognition.Form1.button1_Click(Object sender,
EventArgs
e) in E:\FaceRecognition\FaceRecognition\Form1.cs:line 78
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs
mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message&
m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.Unsa***feNativeMethods.IMsoCo mponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FaceRecognition.Program.Main() in e:\FaceRecognition
\FaceRecognition\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()- Hide quoted
text -
- Show quoted text -- Hide quoted text -
- Show quoted text -

Also here are the definitions at the begginning of the .cpp file
extern "C" __declspec(dllexport) int GetNum();
extern "C" __declspec(dllexport) int DoEigen();
extern "C" __declspec(dllexport) int LookForFaces(char* place);
extern "C" __declspec(dllexport) int AddFace();
extern "C" __declspec(dllexport) int StartCamera();
extern "C" __declspec(dllexport) int StopCamera();- Hide quoted text -

- Show quoted text -


May 7 '07 #9
I put it here
E:\FaceRecognition\FaceRecognition\bin\Debug
But still get the same error.

I also tried
[DllImport("c:\\Windows\\system32\\FaceRecog.dll")]
and
[DllImport(@"c:\Windows\system32\FaceRecog.dll")]
but with the same error
On May 7, 3:32 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Ringo,

If the path to the DLL is this:

"c:\Windows\system32\FaceRecog.dll"

Then your DllImport needs to be this:

[DllImport(@"c:\Windows\system32\FaceRecog.dll")]

Or this:

[DllImport("c:\\Windows\\system32\\FaceRecog.dll")]

Also, you say you put the dll one directory down from where the .sln
file is, which would be the project directory, but that isn't where the
output EXE is built. Place it in that directory and see if it works without
the full path.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Ringo" <ringo.da...@gmail.comwrote in message

news:11**********************@o5g2000hsb.googlegro ups.com...
I've tried somethign like
[DllImport("c:\Windows\system32\FaceRecog.dll")]
public static extern int StartCamera();

But it did not like the "\"'s.

I also tried putting the dll where the .sln file goes and down 1
directory where the rest of the files go and got the same result.
still no luck.

On May 7, 2:39 pm, "Nicholas Paldino [.NET/C# MVP]"

<m...@spam.guard.caspershouse.comwrote:
Have you tried hard-coding the path to the dll just to see if it
works?
Also, is the facerecog.dll stand-alone? If so, place it in the same
directory as your application and it should work.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Ringo" <ringo.da...@gmail.comwrote in message
news:11**********************@h2g2000hsg.googlegro ups.com...
On May 7, 1:29 pm, Ringo <ringo.da...@gmail.comwrote:
I jsut got the .H file used. i was going by the LISP code. I'm not a C+
+ guy at all, but I don't see anything in the .H file that has to do
with the function names called. Am I missing somethign here?
// FaceRecog.h : main header file for the FACERECOG DLL
//
#if !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)
#define
AFX_FACERECOG_H__484912E7_8723_407A_91D6_39A24AD3B 3E4__INCLUDED_
#if _MSC_VER 1000
#pragma once
#endif // _MSC_VER 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
///////////////////////////////////////////////////////////////////////////***//
// CFaceRecogApp
// See FaceRecog.cpp for the implementation of this class
//
class CFaceRecogApp : public CWinApp
{
public:
CFaceRecogApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFaceRecogApp)
public:
//}}AFX_VIRTUAL
//{{AFX_MSG(CFaceRecogApp)
// NOTE - the ClassWizard will add and remove member
functions here.
// DO NOT EDIT what you see in these blocks of
generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
///////////////////////////////////////////////////////////////////////////***//
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations
immediately before the previous line.
#endif // !
defined(AFX_FACERECOG_H__484912E7_8723_407A_91D6_3 9A24AD3B3E4__INCLUDED_)
On May 7, 1:20 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Can you show the header file for C++ to access this? You woud
probably
have more people able to help if you provided that, and it would be
easier
to show you the declarations you would need.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Ringo" <ringo.da...@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
the LeafProjecthttp://www.leafproject.orghasaDLLfor Face
recognition. it is written in C++ but they interface to it from
Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.
;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")
; an interface function:
; -1 = ERROR: camera failed to start
; 0 = camera on successfully
(fli:define-foreign-function
(Start-Camera "StartCamera")
()
:result-type :int)
; an interface function:
; -1 = ERROR: camera failed to stop
; 0 = camera off successfully
(fli:define-foreign-function
(Stop-Camera "StopCamera")
()
:result-type :int)
; an interface function:
; returns the number of face images in the database
(fli:define-foreign-function
(Get-Number-Images "GetNum")
()
:result-type :int)
; an interface function:
; -2 = ERROR: write error
; -1 = ERROR: could not create values.txt file
; 0 = eigens created and stored successfully
(fli:define-foreign-function
(Calc-Eigens "DoEigen")
()
:result-type :int)
; an interface function
; -1 = ERROR: could not rename or add face
; 0 = face added sucessfully
(fli:define-foreign-function
(Add-Face "AddFace")
()
:result-type :int)
; an interface function
; -4 = ERROR: could not save face image
; -3 = ERROR: could not read coefficient file
; -2 = ERROR: could not capture
; -1 = ERROR: could not load classifier cascade
; 0 or more = number of faces detected... if only one face
detected,
then
; return string = image number as a string, eg. "6" means image 6
(fli:define-foreign-function
(Look-For-Faces "LookForFaces")
((return-string (:reference-return (:ef-mb-string :limit 256))))
:result-type :int
:lambda-list (&aux return-string)
:language :c
:calling-convention :cdecl
:result-type :int)
So from that I looked up Pinvoke and wrote this code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FaceRecognition
{
public partial class Form1 : Form
{
[DllImport("facerecog.dll")]
public static extern int StartCamera();
[DllImport("FaceRecog.dll")]
public static extern int StopCamera();
[DllImport("FaceRecog.dll")]
public static extern int GetNum();
[DllImport("FaceRecog.dll")]
public static extern int DoEigen();
[DllImport("FaceRecog.dll")]
public static extern int AddFace();
[DllImport("FaceRecog.dll")]
public static extern int LookForFaces();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int result = StartCamera();
Console.WriteLine(" startcamera = " + result);
}
}
}
When I click the button to do StartCamera I get the following
message
like it cannot find the DLL (which is in windows/system32). I have
tried moving the DLL to the C# apps directory too but that did not
help either. What am I doing wrong?
Thanks
Ringo
System.DllNotFoundException was unhandled
Message="Unable to load DLL 'facerecog.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
Source="FaceRecognition"
TypeName=""
StackTrace:
at FaceRecognition.Form1.StartCamera()
at FaceRecognition.Form1.button1_Click(Object sender,
EventArgs
e) in E:\FaceRecognition\FaceRecognition\Form1.cs:line 78
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs
mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message&
m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.Unsa****feNativeMethods.IMsoC omponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at

...

read more »- Hide quoted text -

- Show quoted text -

May 7 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brett Robichaud | last post by:
I have created a simple background thread to make one pinvoke call into a DLL I've created. My Winforms app spawns the thread in the form load event then go about it's business. The problem is...
5
by: vertigo | last post by:
Hello I use some win 32 API function for example: HANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD...
6
by: Pucca | last post by:
I have a program that originally compiles into a exe file. I changed the compile option to generate dll file. This program calls a com component. Can I use pinvoke in C# to call it? The...
8
by: Rajesh Soni | last post by:
Hi! I'm getting a PInvoke error while trying to execute the following code... declaration: Structure POINTAPI Dim x As IntPtr
0
by: sd | last post by:
Hi all, I have seen this useful Add-in to get the proper Dllimport sentence to use native code in managed applications. I have tested that add-in in VS.NET 2005 (with .NET CF 2.0) and I have...
7
by: Rymfax | last post by:
I would really appreciate it if someone could help me figure out what I'm doing wrong trying to PInvoke SetupDiEnumDriverInfo. All the other PInvokes i've done up to this point work fine. Whenver...
0
by: Benosham | last post by:
I have been playing around with trying to PInvoke GDI+ from C#, I made recently made the transition from C/C++ to C# and I really like the language, however being the old fashioned programmer I am I...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
2
by: Jeff A | last post by:
I am trying to use pInvoke and I need to pass some data from a C++ dll to C# app and vice-a-versa. The data which needs to be passed to C# app is WCHAR* in the dll. How do I marshal them? Do I...
3
by: Siegfried Heintze | last post by:
Can someone kindly help me finish my attempt at pinvoke? HKL is a void* and I don't know how to translate it. //static extern UInt32 MapVirtualKeyExW(UInt32 uCode, UInt32 uMapType, HKL dwhkl); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.