Hello ppl!
I have this program, it is a Updater, it will download many files to a temp dir and then replace the old ones.
Every time before update, I must check the program version, loading an assembly and getting the classType, then getting a static field value. No problem here, but, this assembly file will also be replaced in the new downloaded version, and I won't be able to replace the file because it hasn't been unloaded and the domain still using it, even if I create another domain and unload it before replacing. Any help Please!!
The loading version code is like this:
// Creating a new domain AppDomain productionDomain = AppDomain.CreateDomain("ProductionDomain");
// Loading the assembly Assembly productionAssembly = Assembly.LoadFile(productionDLLFile);
// Loading into the domain productionDomain.Load(productionAssembly.GetName());
// Getting the class type Type productionType = productionAssembly.GetType("Version.ProductionVersion");
// Getting the field info FieldInfo versionFieldInfo = productionType.GetField("CURRENT_VERSION", BindingFlags.Public | BindingFlags.Static);
// Getting the field value version = versionFieldInfo.GetValue(null).ToString();
// Unloading the domain AppDomain.Unload(productionDomain);
I also tried to copy the file to a temp dir and loading the assembly from this temp file, it won't work.
Thanks
.NET Development29
|