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

C# project with a C++ DLL

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

Jan 9 '06 #1
2 1517
Replied to the same question you posted a couple of hours ago,
Willy.

"Victor" <bi******@chefmail.de> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
| 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
|
Jan 9 '06 #2
Sorry folks,

the multiple posting has resulted due to the following circumstances :

I posted my question once and could not see it in the news for several
hours. So I thought, it did not work somehow. I reposted it once again,
and within several hours it did not appear.

As it is very important for me, I tried again... with no effect.

Well, now all postings have emerged from Nowhere...

Sorry... I cannot explain this...

Victor

Jan 9 '06 #3

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

Similar topics

0
by: public heath vb developer | last post by:
We have a solution with 29 projects including a main menu and 28 dlls. One of the projects (Project B) was created by copying an existing project (Project A), making changes including the assembly...
2
by: Rudy Ray Moore | last post by:
How can I modify the project build order of a multi-project workspace under "Visual Studio .net 2003 7.1 c++"? I tried to modify the .sln by hand to influence the build order, but it didn't seem...
1
by: Jerad Rose | last post by:
Hello, I have searched all over for the answer to this, to no avail. I have a web project already set up and running on a remote server, that I created from my home computer. I am now trying...
11
by: Dave | last post by:
I copied the project files from an ASP.NET project on one computer and want to create the project on another computer, There is no connection between the two computers so I simply copied the...
4
by: Brad | last post by:
I'm not one to rant or flame....so please excuse me while I do so for this once. I've now spent a bit of time working with VS2005 beta 2 to see how it functions for web development, especially how...
7
by: Mantorok | last post by:
Hi all We have an ASP.Net project (and the Solution) under source-control. Here is the example - I create the Solution, I create an ASP.Net project and then check it all in to source control,...
6
by: liu | last post by:
Hi all, in my vb.net solution, i have 3 project: 1. Main-this is the startup or the base of my window application. 2. Sales-this is the project that contains all the sales info 3. Product-this...
9
by: Anubhav Jain | last post by:
Hi, I am having few .net source files(.cs or .vb) and I want to dynamically generate the corresponding .net project file(.csproj or .vbproj) for them without using visual studio.So that I could...
3
by: Jerad Rose | last post by:
This is regarding Visual Studio 2003 (framework 1.1). We have several projects/libraries. Of course, many of these reference each other. If we only had one solution, we would simply add all of...
29
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2 computer. I'm using a web form. How do I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.