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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:30:46+00:00 2026-05-23T02:30:46+00:00

That is what i am trying to do: I created the class that i

  • 0

That is what i am trying to do:

I created the class that i want to be the parameter that will be passed between two app domains. In the file ClassLibrary1.dll:

    [Serializable]
    public class MyClass
    {          
        public string mystr = "NotWorking!";

         public MyClass(string _mystr)
         {
            mystr = _mystr;
         }            
         public override string ToString()
         {
             return mystr;
         }
}

Then i created another class that will be the class that will recive MyClass as parameter in otherdomainclass.dll:

public class OtherDomainClass : MarshalByRefObject, IOtherDomainClass
{
    #region Implementation of IOtherDomainClass

    private MyClass my;
    public MyClass getParam()
    {
        return my;
    }

    public void setParam(MyClass _param)
    {
        my = _param;
    }

    #endregion
}

and defined interface for that class in in iotherdomainclass.dll:

public interface IOtherDomainClass
{
    MyClass getParam();
    void setParam(MyClass _param);
}

and now I am trying to run the following test :

[TestMethod()]
    public void PassMyclassBetweenDomains()
    {
        domain = AppDomain.CreateDomain(appDomainName);
        otherClass = domain.CreateInstanceFromAndUnwrap(location, "OtherDomain.OtherDomainClass") as IOtherDomainClass;
        Assert.IsNotNull(otherClass);
        otherClass.setParam(new MyClass("Working!"));
        string sparam = otherClass.getParam().ToString();
        Assert.AreEqual(sparam, "Working!");
        AppDomain.Unload(domain); 
    }

the test fails with following error:

Test method SerizalizableDataTypesTest.ParamCollectionTest.PassMyclassBetweenDomains threw exception 
    System.Runtime.Serialization.SerializationException: Unable to find assembly        'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Sorry about the long story I am not sure what part I am doing wrong. Or if all the code is wrong from the beginning could you please help me to recreate it.

Thank you very much!!!

  • 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-23T02:30:47+00:00Added an answer on May 23, 2026 at 2:30 am

    Since the MyClass type you created is in a assembly that has not yet been loaded in the second AppDomain, consider loading that assembly directly in the 2nd AppDomain.

    Your example class is more complicated than it needs to be because you are not doing anything that requires custom serialization/deserialization code. This will be easier to maintain:

    [Serializable]
    public class MyClass
    {
       public string mystr = "NotWorking!";
       public MyClass(string _mystr)
       {
          mystr = _mystr;
       }
       public override string ToString()
       {
          return mystr;
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a simple class that shows what I am trying to do without
I'm trying to create a generic class in PHP that will provide a way
I am trying to create a class that implements the IUnknown interface. I have
I'm trying to create a class that can instantiate arrays at runtime by giving
I'm trying to create a LINQ to SQL class that represents the latest version
I'm trying to create a UserControl that inherits from a generic class. It does
I was trying to create an extension that could slice any array-like class (since
I'm trying to figure out the best way to create a class that can
I have created a datatable and trying to insert that datatable through SqlBulkCopy but
I'm trying to test an OpenFileDialog that is created when the user clicks on

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.