I have an application that is referencing a dll that will keep changing to a newer version (with backwards compatibility).
My app (built in visual studio 2015) will work with any version - the problem is - i need to reference the dll without specifying the version bec the latest version dll will constantly be replacing the dll in my project (office requirements) and i dont want to recompile my project every time the dll is updated
I tried the following:
setting <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
in my .csproj file
AppDomain.CurrentDomain.AssemblyResolve += delegate (object s, ResolveEventArgs re)
{
AssemblyName theName = new AssemblyName(re.Name);
if (theName.Name == "name, version, key")
{
return Assembly.LoadFile("name without version");
}
return null;
};
im not really sure where to put the second thing that i tried but nothing seems to be working!!
A neater way would be using the AssemblyResolve event -
Something like the following:
AppDomain.CurrentDomain.AssemblyResolve += (sender, argsAssembly) =>
{
if (argsAssembly.Name.StartsWith the name of your dll)
return Assembly.Load(load the dll);
return null;
};