jeudi 23 mars 2017

C# Reflection dll but not call constructor? when the constructor need to input parameter

this is my TcpipManager.dll

namespace TCP.QQ
class TcpipManager
{
    public TcpipManager(string ip)
    { 
       //do something with connect device by ip parameter;
    }   
    public bool ChickConnectStatus()
    {
      bool flag = //device connect status;
      return flag;
    }
}

That is my Code to Reflection TcpipManager.dll

Assembly myLibrary = Assembly.LoadFile(fullpath+\TcpipManager.dll");

Type _dllClass = myLibrary.GetType("TCP.QQ.TcpipManager");

object clsInstance = Activator.CreateInstance(_dllClass , new object[] { "192.168.2.7" });

it is working(no show error message and can get its constructor), but it does not connect to the device.

when I import TcpipManager.dll without reflection.

TcpipManager _tt = new TcpipManager("192.168.2.7");

It is working(no show error message and can get its constructor), and It can connect to the device.

why?





Aucun commentaire:

Enregistrer un commentaire