Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C++ Libraries / July 2003

Tip: Looking for answers? Try searching our database.

a question about communication between C# and C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Liu Guidong - 15 Jul 2003 04:36 GMT
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
Mark Mullin - 22 Jul 2003 20:51 GMT
It may be that it simply can't find the dll.

Windows searchs for DLLS in your local directory and then the system path.
Make sure your dll and exe are in the same directory, then launch the exe
> Dear friends,
> I have a question about the communication between C# and
[quoted text clipped - 60 lines]
> reagrds,
> Liu Guidong

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.