tags:

views:

31

answers:

3

I have created CMyClass,in which defined one method CallMe().when I build this project MyProject.dll is generated. Now in some another project, I want to call CallMe of CMyClass . can anybody tell me how to do it ? Thanks in advance....

A: 

Assuming this is in visual studio..

You need to add a reference to your library from your project, once you have done this you can create an instance of your class and call your method, providing that the class and method is public (or protected if deriving from).

You should be able to do something like :

Yournamespace.CMyClass myClass = new Yournamespace.CMyClass();
myClass.CallMe();
Richard Friend
A: 

You should add a reference to the MyProject.dll to your new project,then, create an object of CMyClass: CMyClass mClass=new CMyClass(); mClass.CallMe();

  • Be sure that the CMyClass class is a public class and the Callme() method is also public
Hadad
A: 

Edit: In C++ just #include the header file and include the .lib file while linking. Or call LoadLibrary to load the DLL. This MSDN page will give you more details.

This is assuming it's not a COM DLL, if it is, things would be somewhat different.

ho1
Sorry....I m using c++.One thing that i m not getting that how I will bw able to create object of some class which is defined in another project.
bharat
@bharat: Just #include the header file and include the .lib file while linking.
ho1
@bharat: amended my answer
ho1