Click here to Skip to main content
15,886,110 members
Home / Discussions / C#
   

C#

 
Questiondll function Pin
Member 5903102-May-10 19:40
Member 5903102-May-10 19:40 
AnswerRe: dll function Pin
Calla2-May-10 20:10
Calla2-May-10 20:10 
GeneralRe: dll function Pin
Member 5903102-May-10 20:12
Member 5903102-May-10 20:12 
GeneralRe: dll function Pin
Pete O'Hanlon2-May-10 20:52
mvePete O'Hanlon2-May-10 20:52 
AnswerRe: dll function Pin
ThatsAlok2-May-10 20:15
ThatsAlok2-May-10 20:15 
GeneralRe: dll function Pin
Member 5903102-May-10 20:19
Member 5903102-May-10 20:19 
GeneralRe: dll function Pin
Calla2-May-10 22:24
Calla2-May-10 22:24 
GeneralRe: dll function Pin
Abdul Rahman Hamidy2-May-10 22:39
Abdul Rahman Hamidy2-May-10 22:39 
as calla suggested, bellow is the simple way to do it.
string asseblyId = @"NewAssembly,Version=1.0.0.0,Culture=neutral,PublicKeyToken=531174506d670b8c";
            ObjectHandle Handle=Activator.CreateInstance(asseblyId, "NewAssembly.ClassName");
            object obj = Handle.Unwrap();
            object[] parm = new object[] { 2, 4 };
            object[] parm1 = new object[] { "Hello" };
            Type t = obj.GetType();
            //Invoketion of the Method...........
            t.InvokeMember("DoIt", BindingFlags.Public | BindingFlags.NonPublic|BindingFlags.InvokeMethod|BindingFlags.Instance ,null , obj ,null);
            int i=(int)t.InvokeMember("Add", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance, null, obj,parm);
            Console.WriteLine(i);
            //Set And Get the property 
            t.InvokeMember("Name", BindingFlags.Public | BindingFlags.SetProperty|BindingFlags.Instance , null, obj, parm1);
            string strname=(string)t.InvokeMember("Name", BindingFlags.Public|BindingFlags.GetProperty| BindingFlags.Instance, null, obj, null);
            Console.WriteLine(strname);

and bellow is the methods for class in dll
public class Employee
    {
     public string _name;
     public int _age;
     public string _address;
     public  string _id;
        public Employee()
        {
        }
        public string Name
        {
            get
            {
                return this._name; 
            }
            set
            {
                this._name = value;
            }
        }
        public int Age
        {
            get
            {
                return this._age;
            }
            set
            {
                this._age = value; 
            }
        }
        public string ID
        {
            get
            {
                return this._id; 
            }
            set {
                this._id = value; 
            }
        }
        public int Add(int i, int j)
        {
            return i + j;
        }
        public void DoIt()
        {
            Console.WriteLine("Welcome from DO it"); 
        }
        public override string ToString()
        {
            return String.Format("ID :{0} Name:={1} Age{2}", this._id, this._name, this._age);
        }   
    }

hope this helps!
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan

GeneralRe: dll function Pin
ThatsAlok3-May-10 3:14
ThatsAlok3-May-10 3:14 
QuestionActive directory Group Enabled or Not Pin
Tiger4562-May-10 18:22
Tiger4562-May-10 18:22 
AnswerRe: Active directory Group Enabled or Not Pin
Michel Godfroid2-May-10 19:06
Michel Godfroid2-May-10 19:06 
QuestionNeed help on c# please Pin
kibr9872-May-10 13:34
kibr9872-May-10 13:34 
AnswerRe: Need help on c# please Pin
Luc Pattyn2-May-10 13:49
sitebuilderLuc Pattyn2-May-10 13:49 
QuestionBest way to access a database Pin
Terence van Schalkwyk2-May-10 9:09
Terence van Schalkwyk2-May-10 9:09 
AnswerRe: Best way to access a database [modified] Pin
PIEBALDconsult2-May-10 9:35
mvePIEBALDconsult2-May-10 9:35 
AnswerRe: Best way to access a database [modified] PinPopular
Pete O'Hanlon2-May-10 9:52
mvePete O'Hanlon2-May-10 9:52 
GeneralRe: Best way to access a database Pin
PIEBALDconsult2-May-10 9:56
mvePIEBALDconsult2-May-10 9:56 
GeneralRe: Best way to access a database Pin
Pete O'Hanlon2-May-10 10:10
mvePete O'Hanlon2-May-10 10:10 
GeneralRe: Best way to access a database Pin
PIEBALDconsult2-May-10 10:29
mvePIEBALDconsult2-May-10 10:29 
GeneralRe: Best way to access a database Pin
Pete O'Hanlon2-May-10 10:33
mvePete O'Hanlon2-May-10 10:33 
GeneralRe: Best way to access a database Pin
PIEBALDconsult2-May-10 10:53
mvePIEBALDconsult2-May-10 10:53 
GeneralRe: Best way to access a database Pin
Terence van Schalkwyk2-May-10 20:01
Terence van Schalkwyk2-May-10 20:01 
GeneralRe: Best way to access a database Pin
Pete O'Hanlon2-May-10 20:38
mvePete O'Hanlon2-May-10 20:38 
GeneralRe: Best way to access a database Pin
Terence van Schalkwyk2-May-10 20:58
Terence van Schalkwyk2-May-10 20:58 
GeneralRe: Best way to access a database Pin
Pete O'Hanlon2-May-10 21:21
mvePete O'Hanlon2-May-10 21:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.