Answer the question
In order to leave comments, you need to log in
What is the problem with dynamic DLL linking?
Good afternoon! This is the problem:
1) I have crooked hands
2) I'm trying to deal with libraries in C #
3) the dll is called ConsoleClient.dll
3) The bottom line is this: I connect the dll dynamically
Assembly a = Assembly.Load("ConsoleClient");
Object o = a.CreateInstance("Program");
Type t = a.GetType("Program");
Object[] numbers = new Object[2];
numbers[0] = 2;
numbers[1] = 3;
MethodInfo mi = t.GetMethod("add");
Console.WriteLine(mi.Invoke(o, numbers));
Console.ReadLine();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Program
{
public int add(int a, int b)
{
return a + b;
}
}
Answer the question
In order to leave comments, you need to log in
Assembly a = Assembly.LoadFrom("ConsoleClient.dll");
Type[] types = a.GetTypes();
foreach (Type z in types)
Console.WriteLine("--> " + z);
Console.WriteLine();
Object o = a.CreateInstance("Program");
Type t = a.GetType("ConsoleClient.Program");
Object[] numbers = new Object[2];
numbers[0] = 2;
numbers[1] = 3;
MethodInfo mi = t.GetMethod("add");
Console.WriteLine(mi.Invoke(o, numbers));
//чтобы консоль мгновенно не закрылась
Console.ReadLine();
What am I doing wrong?all
I put it wrong, by the phrase "only assembly connection" I meant just dynamic connection of the assembly, either through Assembly.Load or AppDomain.Load ()+
The goal is for the dll to be loaded from the server and exist only in RAM, so such dances with a tambourine.. well, let's start with the fact that you need to have correctly compiled versions of the DLL for all possible client OS .. this is initially the choice of the path of terrible hemorrhoids .. I think this can be finished))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question