The MindFusion Forums
Flow Diagramming Components >> ASP.NET >> Reading files created with an older WinForms version of MindFusion
https://mindfusion.eu/Forum/YaBB.pl?num=1528386369

Message started by David Long on Jun 7th, 2018 at 3:46pm

Title: Reading files created with an older WinForms version of MindFusion
Post by David Long on Jun 7th, 2018 at 3:46pm
I'm writing an ASP .NET version of software I have previously written with WinForms/Diagramming for Winforms and would like to read files created with that older software.  The error I get on a file read is:

"Could not load file or assembly 'MindFusion.Common, Version=1.3.1.18503, Culture=neutral, PublicKeyToken=7fed53ada5b92263' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

So the old data file is referencing types in an older copy of MindFusion.Common.dll with a different version and PublicKeyToken.  The differing PublicKeyToken means that I cannot use a bindingRedirect in Web.config, so after a web search I have come up with the following which I have added to web.config

<dependentAssembly>
        <assemblyIdentity name="MindFusion.Common" Culture="neutral" publicKeyToken="7fed53ada5b92263"/>
        <codebase version="1.3.1.18503" href="WinForms\MindFusion.Common.dll" />
      </dependentAssembly>

      <dependentAssembly>
        <assemblyIdentity name="MindFusion.Common" Culture="neutral" publicKeyToken="dd7449df9ffcc455"/>
        <codebase version="1.3.2.450" href="WebForms\MindFusion.Common.dll" />
      </dependentAssembly>

I have created two separate folders (WinForms and WebForms) that contain the two sets of DLLs, but I still get the same error every time.

Any help gratefully received.
DavidL


Title: Re: Reading files created with an older WinForms version of MindFusion
Post by Slavcho on Jun 8th, 2018 at 8:16am
I think the SerializationBinder property we discussed some time ago should help for this too -
https://mindfusion.eu/Forum/YaBB.pl?num=1486395394/15#15

Regards,
Slavcho

Title: Re: Reading files created with an older WinForms version of MindFusion
Post by David Long on Jun 8th, 2018 at 2:54pm
That seems to partially work.  The SerializationBinder tells my web application where to find the box tag class, an object of which is attached to each chart box.  But the box tags contain a MindFusion.Drawing.Pen and the SerialisationBinder does not seem to be called again to allow me to specify the new ASP .NET version of MindFusion.Common.dll that is part of my web application.  Is the Pen class in these two DLLs actually compatible?  Maybe it does not work for a reason!

Note:  I've also tried the AssemblyResolve route, but that gives the same result...

        void Application_Start(object sender, EventArgs e)
        {

            
            // Add event handler for Assembly resolution
            AppDomain.CurrentDomain.AssemblyResolve += AssembleyResolveEventHandler;
        }

        private static Assembly AssembleyResolveEventHandler(object sender, ResolveEventArgs args)
        {
            var name = new AssemblyName(args.Name);

            if (name.Name == "MindFusion.Common")
            {
                Type t = typeof(MindFusion.Drawing.Pen);
                Assembly a = Assembly.GetAssembly(t);
                return a;
            }

            return null;
        }

I appreciate that this may be more of a .NET problem than a MindFusion one, but any help appreciated.
DavidL

Title: Re: Reading files created with an older WinForms version of MindFusion
Post by David Long on Jun 11th, 2018 at 8:20am
Come to think of it - I think that I can add a feature to the desktop version of my software - a sort of 'Prepare for Web' feature that re-writes the box tags to be more in line with the features of the web version.

No more help needed.
DavidL

Title: Re: Reading files created with an older WinForms version of MindFusion
Post by Slavcho on Jun 11th, 2018 at 9:04am
The custom binder should be used both for the root Tag object and is also assigned as BinaryFormatter.Binder. Are you saving in XML or binary format, and in what way does the root tag object save pens?

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.