473,320 Members | 2,004 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,320 software developers and data experts.

a question about the communication between C# and C++

Dear friends,
I have a question about the communication between C# and
C++.
Can anyone help me ??
I have written a C# dll fies named "TestFordll2.dll",as
fllow:

using System;
namespace TestForDll2
{
public class TestForDll
{
private int result ;
public TestForDll()
{
result = 0;
}
public TestForDll(int a , int b)
{
result = 0;
result = a + b;
}
public int Out()
{
return result;
}
}
}

And I also wrote a C++ file named "Call.cpp" to call the
C# dll file "TestForDll2.dll",as follow:

#include <iostream.h>
#using <TestForDll2.dll>
#using <mscorlib.dll>
using namespace System;
using namespace TestForDll2;
int main()
{
int i = 0;
TestForDll2::TestForDll *a = new
TestForDll2::TestForDll(1,2);
i = a->Out();
cout<<"the result is"<<i<<endl;

}
And I also set the properties of the C++ file by using the
follwo:
1. Open the project's Property Pages dialog box.
Properties.
2. Click the C/C++ folder.
3. Click the General property page.
4. Modify the Resolve #using References property making
it pointing to the "TestForDll2.dll" file
when I build the project ,everyting is ok.But when I run
the project ,an error occured :can not

find file or assembly "TestForDll2",or can not find one of
its relier"
why??
Can anyone hlep me? Thanks

reagrds,
Liu Guidong
Nov 16 '05 #1
1 2971
Hi Liu,
You probably don't have TestForDll2.dll in the PATH so the runtime cannot
find it. Try putting it in the same directory where the C++ .exe is.

--
Keiji Oenoki
Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "Liu Guidong" <lg*********@hotmail.com>
Sender: "Liu Guidong" <lg*********@hotmail.com>
Subject: a question about the communication between C# and C++
Date: Mon, 14 Jul 2003 20:35:16 -0700

Dear friends,
I have a question about the communication between C# and
C++.
Can anyone help me ??
I have written a C# dll fies named "TestFordll2.dll",as
fllow:

using System;
namespace TestForDll2
{
public class TestForDll
{
private int result ;
public TestForDll()
{
result = 0;
}
public TestForDll(int a , int b)
{
result = 0;
result = a + b;
}
public int Out()
{
return result;
}
}
}

And I also wrote a C++ file named "Call.cpp" to call the
C# dll file "TestForDll2.dll",as follow:

#include <iostream.h>
#using <TestForDll2.dll>
#using <mscorlib.dll>
using namespace System;
using namespace TestForDll2;
int main()
{
int i = 0;
TestForDll2::TestForDll *a = new
TestForDll2::TestForDll(1,2);
i = a->Out();
cout<<"the result is"<<i<<endl;

}
And I also set the properties of the C++ file by using the
follwo:
1. Open the project's Property Pages dialog box.
Properties.
2. Click the C/C++ folder.
3. Click the General property page.
4. Modify the Resolve #using References property making
it pointing to the "TestForDll2.dll" file
when I build the project ,everyting is ok.But when I run
the project ,an error occured :can not

find file or assembly "TestForDll2",or can not find one of
its relier"
why??
Can anyone hlep me? Thanks

reagrds,
Liu Guidong


Nov 16 '05 #2

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

Similar topics

0
by: Srinivas B.S.S | last post by:
Hi, I am using MyODBC 3.51.06 on solaris. When a ODBC call fails to execute due to communication problems with database server, according to ODBC reference, sqlstate should be set to 08S01...
0
by: Michael.Coll-Barth | last post by:
Actually, the continuous complaining and ranting about Xah's 'postings' are far worse than Xah's actual postings. I can filter his stuff to /dev/null. The drivel that follows is almost as bad as...
1
by: xixi | last post by:
i have catalog a remote database on my local db2 server, but now the remote database server with same machine name but the ip address changed, so i remove the old one, and try to catalog again...
3
by: Tim Reynolds | last post by:
I support a .Net application running on a SERVER accessing MF Db2 data. Occasionally, we have some type of connection problem that we have been unable to debug up to this point. We typically...
1
by: Praveen | last post by:
Hi, I have installed WebSphere Portal on AIX and connected to DB2 on a remote machine, Getting the followin errors when trying to get the values from database thru applications installed on...
2
by: xeyder | last post by:
Hi everyone.. I need help about graph theory ( network problems) .. I have below problem . Does anyone know any existence algorithms or solutions to this problem ?? The Problems is: "...
21
by: dast | last post by:
Hi, I'm having trouble letting my background thread tell my main thread what to do. I'm trying to tell my main thread to open a form, but when my background thread ends, the form that I...
2
by: xeyder | last post by:
Hi everyone.. I need help about graph theory ( network problems) .. I have below problem . Does anyone know any existence algorithms or solutions to this problem ?? The Problems is: " We...
1
by: Tony | last post by:
Hello! This is the scenario that we want to implement. Assume we have three computers called client1, client2 and client3 that must be able to register itself on server A. Meaning telling...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.