Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 597173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:15:06+00:00 2026-05-13T16:15:06+00:00

I would like to migrate me previously serialized objects in database to new schema.

  • 0

I would like to migrate me previously serialized objects in database to new schema.

My previous object.

Public interface MyReport
{

    string Id { get; set;}

    string Name { get; set;}

    Dictionary<string, string> PropColl { get; set;}
}

But for some reasons we had to make interface changes

Public interface IMarkme
{
}

Public interface MyReport<T> where T : Imarkme
{

    string Id { get; set;}

    string Name { get; set;}

    T ExtendedProp { get; set;}
}

Public NewProp : Imarkme
{
    /// some code here 
}

So as you can see my interface has been modified and I would like to migrate my serialized objects which were serialized based on MyReport to MyReport
Can someone provide me some input as what kind of utility I should aim to write which can help me achieve migrating my serialized object to new modified interface version.

Thanks,
AG

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:15:06+00:00Added an answer on May 13, 2026 at 4:15 pm

    I have actually done something similar recently, where I have created a simple console application to be able to transform some serialized objects from one version to another. I have simply used both versions of dlls and reflection to read and write the values of different properties. Probably you’ll find this helpful as an inspiration 😉

    static void Main(string[] args)
        {
            object test;
    
            AppDomain.CurrentDomain.AssemblyResolve += domain_AssemblyResolve;
    
    
            using (var con = new SqlConnection(connectionString))
            {
                using (var cmd = new SqlCommand())
                {
                    cmd.CommandText = "select top 1 Data_Blob from dbo.Serialized";
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection = con;
    
                    con.Open();
                    var blob = (byte[])cmd.ExecuteScalar();
    
                    var bf = new BinaryFormatter();
                    var stream = new MemoryStream(blob);
                    bf.AssemblyFormat = FormatterAssemblyStyle.Full;
                    test = bf.Deserialize(stream);
                }
            }
    
            var objNewVersion = Activator.CreateInstance(Type.GetType("ObjectGraphLibrary.Test, ObjectGraphLibrary, Version=1.0.0.10, Culture=neutral, PublicKeyToken=33c7c38cf0d65826"));
    
    
            var oldType = test.GetType();
            var newType = objNewVersion.GetType();
    
            var oldName = (string) oldType.GetProperty("Name").GetValue(test, null);
            var oldAge = (int) oldType.GetProperty("Age").GetValue(test, null);
    
            newType.GetProperty("Name").SetValue(objNewVersion, oldName, null);
            newType.GetProperty("DateOfBirth").SetValue(objNewVersion, DateTime.Now.AddYears(-oldAge), null);
    
    
            Console.Read();
        }
    
        static Assembly domain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            var assName = new AssemblyName(args.Name);
    
            var uriBuilder = new UriBuilder(Assembly.GetExecutingAssembly().CodeBase);
            var assemblyPath = Uri.UnescapeDataString(uriBuilder.Path);
            var codeBase = Path.GetDirectoryName(assemblyPath);
    
            var assPath = Path.Combine(codeBase, string.Format("old\\{0}.{1}.{2}.{3}\\{4}.dll", assName.Version.Major,
                                                     assName.Version.Minor, assName.Version.Build,
                                                     assName.Version.Revision, assName.Name));
    
            return File.Exists(assPath) ? Assembly.LoadFile(assPath) : null;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to migrate a site, but the new URL's are completely different
I have a current 'staging' database in 'heroku' and would like to migrate it
We bought a new Mac and would like to migrate the certificates and private
I would like to migrate all my unit tests from NUnit to MSTest. In
I would like to know if I migrate from Windows Server 2003 to Windows
I would like to migrate to Eclipse 3.5 from Eclipse 3.4, but I am
Our old TFS 2008 installation is getting old, and we would like to migrate
I would like to maintain a list of objects that is distributed between N
I'm starting a new project and would like some advice. The purpose is to
I have a Windows Form project that I would like to migrate toward a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.