Hi everybody !
I would like to consult a guru for the obstacle I cannot tackle alone.
My environment is Visual Studio 2005 under Windows XP.
I have two projects :
(A) A DLL - HerHair.dll - created in the VC++ by the Wizard. Its header
file HerHair.h has the following content :
**************
#ifdef HERHAIR_EXPORTS
#define HERHAIR_API __declspec(dllexport)
#else
#define HERHAIR_API __declspec(dllimport)
#endif
// This class is exported from the HerHair.dll
class HERHAIR_API CHerHair {
public:
CHerHair(void);
// TODO: add your methods here.
};
extern HERHAIR_API int nHerHair;
HERHAIR_API int fnHerHair(void);
**************
This project compiles perfectly.
(B) An EXE, which should use the HerHair.dll. This project is developed
in C# and is of WindowsForms type. I have made an entree in its
reference pointing to the directory where the DLL created in the
project (A) resides.
In the declaration
public class Form1 : System.Windows.Forms.Form {
there must appear an instance of the class exported from the DLL
CHerHair class1;
This project cannot compile. I get the following error :
The type or namespace name 'CHerHair' could not be found (are you
missing a using directive or an assembly reference?)
Well, I tried to put the following before the declaration of the
CHerHair instance :
[DllImport("HerHair.dll")]
- no effect.
I tried to put the declaration of the class CHerHair in the project (A)
within a namespace directive like this :
namespace HerHair {
// This class is exported from the HerHair.dll
class HERHAIR_API CHerHair {
public:
CHerHair(void);
// TODO: add your methods here.
};
extern HERHAIR_API int nHerHair;
HERHAIR_API int fnHerHair(void);
}
and then added to the project (B) this line before the declaration of
the class Form1 :
using HerHair;
The result was only an additional error on this line :
The type or namespace name 'HerHair' could not be found (are you
missing a using directive or an assembly reference?)
So, what could be wrong in all this stuff ?
Many thanks in advance.
Victor