-Fixed deserializing with type name handling and assemblies loaded with Assembly.LoadFrom

This commit is contained in:
James Newton-King
2013-05-02 20:44:58 +12:00
parent da491c3a0f
commit b6816866ba
3 changed files with 18 additions and 2 deletions
@@ -75,4 +75,4 @@ using System.Security;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("5.0.4.16101")]
[assembly: AssemblyFileVersion("5.0.4.16102")]
@@ -92,6 +92,6 @@ using System.Security;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("5.0.4.16101")]
[assembly: AssemblyFileVersion("5.0.4.16102")]
[assembly: CLSCompliant(true)]
@@ -61,6 +61,22 @@ namespace Newtonsoft.Json.Serialization
assembly = Assembly.Load(assemblyName);
#endif
#if !(PORTABLE40 || PORTABLE)
if (assembly == null)
{
// will find assemblies loaded with Assembly.LoadFile outside of the main directory
Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly a in loadedAssemblies)
{
if (a.FullName == assemblyName)
{
assembly = a;
break;
}
}
}
#endif
if (assembly == null)
throw new JsonSerializationException("Could not load assembly '{0}'.".FormatWith(CultureInfo.InvariantCulture, assemblyName));