PersistenceManager.LoadFromXml vs Assembly Versions

8 posts, 0 answers
  1. Koen
    Koen avatar
    27 posts
    Member since:
    Apr 2012

    Posted 31 Jul 2012 Link to this post

    Hi All,


    We use Telerik's PersistenceManager capabilities to save user settings to XML in a relational database (as desribed here).
    In particular, some of RadGridView's settings are stored this way.
    This has worked fine for several months, until we performed an update of our Telerik libraries last week.


    The XML the PersistenceManager produces, contains some type information concerning the types that were serialized to XML,
    and contains lines like this:

    <TI K="-134624143" N="Telerik.Windows.Controls.GridView.GridViewLengthConverter, Telerik.Windows.Controls.GridView, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7" />

    After the Telerik libraries update, this causes an exception because we now use Telerik.Windows.Controls.GridView v2012... 
    When PersistenceManager.LoadFromXml is called, the PersistenceFramework tries to load the Type,
    resulting in a TypeLoadException:

    Could not load file or assembly 'Telerik.Windows.Controls.GridView,
    Version=2011.2.712.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one
    of its dependencies. The located assembly's manifest definition does not match
    the assembly reference. (Exception from HRESULT: 0x80131040)


    What is the best option to avoid this on Telerik updates?
    Can we tell the Serializer not to Save the fully qualified type name to XML?


    Thanks for your time,
    Koen




  2. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 03 Aug 2012 Link to this post

    Hi Koen,

     Basically, the full assembly qualifying name is required to be saved, as there is no way to restore the type when deserializing. However, it is possible to change only the version of the type. We have already resolved this issue so that the PersistenceManager can support cross version deserialization. This should be available with the next internal build.

    Regards,
    Alex Fidanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Alfons
    Alfons avatar
    14 posts
    Member since:
    Mar 2012

    Posted 05 Oct 2012 Link to this post

    Dear Alex,

    The issue you are referring to is a Silverlight issue. Is this cross version deserialization available for WPF as well?

    Regards,

    Alfons

    BTW In the PIT I cannot discover a date when the issue is solved, only when is submitted. I would like to see when the last changes where made to an issue, to get an idea if there has been any progress to an issue lately.
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 10 Oct 2012 Link to this post

    Hello Alfons,

    The issue is resolved for both Silverlight and WPF. It was resolved on 06.08.2012 so you can use it with the latest official release - Q2 2012 SP2 (v. 2012.2.0912).

    Also, thank you for your feedback on our PITS. We will definitely have it in mind when discussing how to improve the system.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Jeff
    Jeff avatar
    25 posts
    Member since:
    Feb 2009

    Posted 06 Mar 2013 Link to this post

    Tina,

    You mentioned that this has been resolved as of 2012.2.0912 however after upgrading to Q1 2013 I'm seeing the following exception when attempting to load perseistent state for a RadGridView control saved in 2012.2.0912. Please note that we have also switched from .NET 3.5 to .NET 4.0 in this process as well. I'm I missing some details on how get this working or is my understanding on how this was resolved incorrect?


    System.IO.FileLoadException occurred
      HResult=-2146234304
      Message=Could not load file or assembly 'Telerik.Windows.Controls.GridView, Version=2012.2.912.35, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
      Source=mscorlib
      FileName=Telerik.Windows.Controls.GridView, Version=2012.2.912.35, Culture=neutral, PublicKeyToken=5803cfa389c90ce7
      FusionLog==== Pre-bind state information ===
    LOG: User = MyDomain\MyUser
    LOG: DisplayName = Telerik.Windows.Controls.GridView, Version=2012.2.912.35, Culture=neutral, PublicKeyToken=5803cfa389c90ce7
     (Fully-specified)
    LOG: Appbase = file:///C:/MySolution/MyProject/bin/Debug/
    LOG: Initial PrivatePath = NULL
    Calling assembly : Telerik.Windows.PersistenceFramework, Version=2013.1.220.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7.
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\MySolution\MyProject\bin\Debug\SmartClient.exe.config
    LOG: Using host configuration file:
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Post-policy reference: Telerik.Windows.Controls.GridView, Version=2012.2.912.35, Culture=neutral, PublicKeyToken=5803cfa389c90ce7
    LOG: Attempting download of new URL file:///C:/MySolution/MyProject/bin/Debug/Telerik.Windows.Controls.GridView.DLL.
    WRN: Comparing the assembly name resulted in the mismatch: Major Version
    ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

      StackTrace:
           at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
           at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
           at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
           at System.Type.GetType(String typeName)
           at Telerik.Windows.Persistence.Serialization.Deserializer.RestoreType(String typeName) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Persistence\Serialization\Deserializer.cs:line 783
      InnerException:

  7. Koen
    Koen avatar
    27 posts
    Member since:
    Apr 2012

    Posted 07 Mar 2013 Link to this post

    We are also still experiencing the same issue in WPF version 2012.3.12.03.40.


    Regards,
    Koen 
  8. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 11 Mar 2013 Link to this post

    Hello Jeff,
    The Persistence Framework saves the dll name and version for each type so that it could load them afterwards and this may cause some problems. With Q2 2012 SP2 (v. 2012.2.0912) we added a new property - AllowCrossVersion and if you set it to True it should fix this issue for our dlls, but it doesn't work for Microsoft dlls! This means that if you've persisted something with 3.5 you'll still need 3.5 installed when you try to load it because the persistence will try to load the older dlls.
    I'd like to ask you for a sample project so that we could test it and give you a workaround or fix if possible.
    I've attached a sample .NET 4.0 project with an XML file which is saved under .NET 3.5 and with older telerik version (2012.2.912.35) but if you load it everything should work fine so could you please examine it and tell us if it works on your side.

    Regards,
    Zarko
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  9. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 11 Mar 2013 Link to this post

    Hi Koen,
    I'd like to ask you for some more information about your case and also could you please examine the attached project from my previous post and see if it helps you?
    We're looking forward to hearing from you.

    Greetings,
    Zarko
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready