we have an application that looks at a shared folder for a newer version of the application.
We came up with the following code to check whether the assemblies versions are different (the running at client, and the one at server shared folder)
//Obtains the current version of the Entry Assembly
versaoAtual = Assembly.GetEntryAssembly().GetName().Version;
//Path for the the new Assembly at a shared folder at server
string arquivoServidor = Path.Combine(maquinaCliente.DiretorioDeploy, @"SAMEDigital.Client.exe");
//If the file does not exist, the version is the same, so it would not be updated
if (!File.Exists(arquivoServidor))
{
versaoNova = versaoAtual;
}
else
{
//Creates a temporary AppDomain for loading the server assembly
AppDomain ad = AppDomain.CreateDomain("TempAppDomainSAMEDigitalClient");
//Obtains the server version of the server assembly
versaoNova = ad.Load(File.ReadAllBytes(arquivoServidor)).GetName().Version;
//Unload the the temporary AppDomain
AppDomain.Unload(ad);
}
But the results are not the expected, both variables display the same version (the version that is actually running). Shouldn´t this work? As we are getting the version of the running assembly and then loading another assembly and acquiring the version of this one.
Could someone, please, clarify what we are doing wrong?
Thanks in advance.