How do I call a function from the dll loaded by me through Assembly of new Domain

Assembly tt = Assembly.LoadFile("E:\\Games\\DC4_PROJECT\\rust_Data\\Managed\\DizzyClient.dll"); AssemblyName tt2 = tt.GetName(); AppDomain news = AppDomain.CreateDomain("hack"); news.Load(tt2); 

It is necessary to call the function void Ready () of the class cjb from tt.

  • @ pavel1787mego - do not be scared - I am the administrator of the game server and decided to remake the cheat menu for myself). Then I don’t go anywhere else) - Sergey
  • @ pavel1787mego rust legacy - so you can answer on my question? - Sergey
  • @ pavel1787mego where does the knowledge of the game - which is void on loading - Sergey
  • one
    Re-read the dialogue, I said - no, I will not answer. I do not know the answer - pavel1787mego
  • @ Alexey Shimansky vsmysle for the public? Right now while I train on the cheat menu - then I will plan for the client for my server via RPC - this will wake up more of unity - and you can dump the dll from the main stream - Sergey

1 answer 1

To call a class method, you need to first create it. To create an instance of your class, you need to make the following sequence of calls. First you need to create a wrapper object class in the domain that you downloaded dll

  ObjectHandle objWrap = news.CreateInstance(tt.FullName, "MyType"); 

This function returns an ObjectHandle object that is used to transfer an object (in a minimized state) between several application domains.
Your cjb class must necessarily inherit from the MarshalByRefObject class , which allows access to an object across application domain boundaries.

After that, you can call the Unwrap function to get an instance of a class created in another domain.

 // Unwrapps the proxy to the MyType object created in the other AppDomain. MyType testObj = (MyType)objWrap.Unwrap(); 

After that, you can call the function of this class.

  • complains that there is no cjb - you need to call cjb.Ready.Init () - Sergey
  • @ Sergey, what line is he complaining about? Is cjb the type of your class? - Alexcei Shmakov
  • cjb is the namespace skrinshoter.ru/s/290817/ZTbZaQyP?a - Sergey
  • cjb is the namespace - Sergey
  • Sergey, I looked at the structure of your library, I gave you enough material in the answer so that you put your values ​​in the right places - Alexcei Shmakov