New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to add different NuGet package versions in plugins #2523
Comments
@shurub3l in this case you have to use the version the admin area uses - 4.1.1 |
But I need a newer version of AutoMapper, that's the problem ... I could update Nop.Admin to use the newer version aswell, but I don't have access to the third party plugin that also uses AutoMapper 4.1.1. |
@shurub3l thanks. we'll think about it |
I found a workaround for my problem. I changed the code to compare full assembly name when checking if an assembly is already loaded and, I added in web.config a codeBase element for every AutoMapper version. This way the different version nuget package assembly is not skipped when loading assemblies and every assembly is loaded from the correct file path. So the method private static bool IsAlreadyLoaded(FileInfo fileInfo)
{
//compare full assembly name
try
{
var fileAssemblyName = AssemblyName.GetAssemblyName(fileInfo.FullName);
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
{
if (a.FullName.Equals(fileAssemblyName.FullName, StringComparison.InvariantCultureIgnoreCase))
return true;
}
}
catch (Exception exc)
{
Debug.WriteLine("Cannot validate whether an assembly is already loaded. " + exc);
}
return false;
//do not compare the full assembly name, just filename
//try
//{
// string fileNameWithoutExt = Path.GetFileNameWithoutExtension(fileInfo.FullName);
// if (fileNameWithoutExt == null)
// throw new Exception(string.Format("Cannot get file extnension for {0}", fileInfo.Name));
// foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
// {
// string assemblyName = a.FullName.Split(new[] { ',' }).FirstOrDefault();
// if (fileNameWithoutExt.Equals(assemblyName, StringComparison.InvariantCultureIgnoreCase))
// return true;
// }
//}
//catch (Exception exc)
//{
// Debug.WriteLine("Cannot validate whether an assembly is already loaded. " + exc);
//}
//return false;
} And added this in web.config file from Nop.Web: <dependentAssembly>
<assemblyIdentity name="AutoMapper" publicKeyToken="be96cd2c38ef1005" culture="neutral" />
<codeBase version="6.1.1.0" href="Plugins\Integration.ServiceBus\AutoMapper.dll" />
<codeBase version="4.1.1.0" href="bin\AutoMapper.dll" />
</dependentAssembly> |
Until we load plugins in separate domains it's better to avoid usage of diffrerent versions. So we don'y plan to support it in the near time |
I am developing a plugin which needs the latest version of AutoMapper (6.1.1). But Nop.Admin aswell as another third party plugin use AutoMapper 4.1.1 (I currently have nopCommerce 3.70, but the problem is the same for all versions of nopCommerce).
The error is the following:
Assembly binding redirect won't work because the plugin versions are very different and the methods have changed.
The text was updated successfully, but these errors were encountered: