Tell me, please, how not to keep the dll, after using the following construction:
Assembly a = Assembly.LoadFile(dll); Type t = a.GetTypes().FirstOrDefault(x => x.Name == "MainDllClass"); MethodInfo mi = t.GetMethod("WorkTimer"); mi.Invoke(null, arguments); Call the WorkTimer method from the MainDllClass class of the dll file. For some reason, after testing, it continues to be used and does not allow overwriting the dll file
hmm it seems like this:
AppDomain dom = AppDomain.CreateDomain("some"); AssemblyName assemblyName = new AssemblyName(); assemblyName.CodeBase = pathToAssembly; Assembly a = dom.Load(assemblyName); Type t = a.GetTypes().FirstOrDefault(x => x.Name == "MainDllClass"); MethodInfo mi = t.GetMethod("WorkTimer"); mi.Invoke(null, arguments); AppDomain.Unload(dom); I will test, then accomplish your goal.