By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,673 Members | 1,268 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,673 IT Pros & Developers. It's quick & easy.

a question about communication between C# and C++

P: n/a
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 13 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.