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 3978492
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:03:15+00:00 2026-05-20T05:03:15+00:00

Case: Pass a unserializable parameter cross AppDomain. Following is some method which i want

  • 0

Case:

Pass a unserializable parameter cross AppDomain.

Following is some method which i want to call in remote domain;

public RemoteClass
{
  public Test(Class1 obj);
  public Test(List<Class1> obj);
}

Define:

Class1    :   un-serializable

[Serializable]
Class2 : Class1  , ISerializable  //mark Class2 serializable
{
    //.....
}

Following code used to test:

using (MemoryStream s = new MemoryStream())
{
    BinaryFormatter f = new BinaryFormatter();
    f.Serialize(s, obj);
}

Test result:

obj                                      result

Class1 obj=new Class1();                 exception

Class1 obj=new Class2();                 success

List<Class1> obj=new List<Class1);       exception  when obj contain some element;
obj.Add(new Class1();   

List<Class1> obj=new List<Class1);       exception  when obj contain some element; //how???
obj.Add(new Class2();

List<Class2> obj=new List<Class2);       success;
obj.Add(new Class2();   

Class1 is not a serializable calss, and I cannot modify it, so I have define Class2 which inherits from Class1 and implements ISerializable. I can pass an instance of Class2 when a method needs a instance of Class1 in test result and this solution is successful, however for List<Class1> this does not work.

  • 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-20T05:03:16+00:00Added an answer on May 20, 2026 at 5:03 am

    How about converting the List<Class1> instance into a list List<Class2> (the following should work as long as you declare a suitable constructor on Class2):

    // using System.Linq;
    List<Class1> inputList = MyInputList();
    List<Class2> outputList = inputList.ConvertAll<Class2>(a => new Class2(a));
    

    You should then be able to serialise List<Class2> just fine.

    You find that you need to convert your serialised list back into a List<Class> before you can use it anywhere that accepts a List<Class1> – a variation on the above should work just as well in reverse.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a test case which will test a list of functions.
case i of 0..99 : Function-call('bobo') ; 100..209 : function-smell('Hobo'); 210..300 : function-yikes('argh'); end;
The case goes as following: You have a Boolean property called FullScreenEnabled. You enter
Time elapsed (time taken?) to run(and pass) my Junit test case is shown as
It appears the query string parameters you can pass to a rest method in
I'm using Boost.Range to pass around some data and a container class for this
Use case: A does something on his box and gots stuck. He asks B
Use case: 3rd party application wants to programatically monitor a text file being generated
Simple case: i put a DataTable in Cache DataTable table = SomeClass.GetTable(); Cache[test] =
I was using a CASE called MAGIC for a system I'm developing, I've never

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.