Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1682


Ignore:
Timestamp:
04/28/09 12:40:29 (15 years ago)
Author:
epitzer
Message:

If type loading with partial name fails, explicitly load assembly with partial name (obsolete interface) to obtain newest assembly from assembly cache. (#604)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/DeSerializer.cs

    r1625 r1682  
    33using HeuristicLab.Persistence.Interfaces;
    44using HeuristicLab.Persistence.Core.Tokens;
     5using HeuristicLab.Tracing;
     6using System.Reflection;
    57
    68namespace HeuristicLab.Persistence.Core {
     
    6870        var map = new Dictionary<Type, object>();
    6971        foreach (var typeMapping in typeCache) {
    70           Type type = Type.GetType(typeMapping.TypeName, true);
     72          Type type;
     73          try {
     74            type = Type.GetType(typeMapping.TypeName, true);
     75          } catch (Exception e) {
     76            Logger.Error(String.Format(
     77              "Cannot load type \"{0}\", falling back to loading with partial name", typeMapping.TypeName));
     78            string[] typeNameParts = typeMapping.TypeName.Split(new[] {','});
     79            Assembly a = Assembly.LoadWithPartialName(typeNameParts[typeNameParts.Length - 1].Trim());
     80            Array.Resize(ref typeNameParts, typeNameParts.Length - 1);
     81            type = a.GetType(string.Join(",", typeNameParts), true);
     82          }
    7183          typeIds.Add(typeMapping.Id, type);
    7284          Type serializerType = Type.GetType(typeMapping.Serializer, true);
Note: See TracChangeset for help on using the changeset viewer.