... not marked as serializable.

G

Guest

Hi again

I have a little problem with "serializable" a control ...

I am creating AppDomain, Assembly and Instance. All works fine.
My "base" class for the instance inherit from:
- System.MarshalByRefObject
- and also my Interface.
In my "base" class I refer to a Form.
I am able to access the form but not the controls. I get the exeption:
Type 'System.Windows.Forms.Form+ControlCollection' in assembly
'System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' is not marked as serializable.

How do I mark this form and/or the controls on it as serializable ??

Thank you for any comment !

Best regards
Frank Uray
 
A

Abhijeet Dev

You can not serialize a form as it holds native references. If it is
absolutely necessary to serialize a windows form, create a custom Form,
inherit from "Form" and implement ISerializable.
I would have marked the form instance "NonSerialized"
(System.NonSerializedAttribute)
 
G

Guest

Hi

Thank you for your answer!
Just one more little question:
Where can I mark the instance as "NonSerialized" ??

I am doing this:
System.AppDomain local_AppDomain =
System.AppDomain.CreateDomain("DynamicDomain");
System.Reflection.AssemblyName local_AssemblyName = new
System.Reflection.AssemblyName();
local_AssemblyName.CodeBase = @"C:\Temp\Test";
local_AssemblyName.Name = "sCONTROL_SSSP";

System.Reflection.Assembly local_Assembly;
local_Assembly = local_AppDomain.Load(local_AssemblyName);

sCONTROLInterface.sCONTROLInterface local_InterfaceObject =
(sCONTROLInterface.sCONTROLInterface)local_AppDomain.CreateInstanceAndUnwrap("sCONTROL_SSSP", "sCONTROL_SSSP.clsRemote");

The class "clsRemote" implements "sCONTROLInterface" Interface
and also "System.MarshalByRefObject".
"public class clsRemote : System.MarshalByRefObject, sCONTROLInterface"
Without System.MarshalByRefObject it wont work ...
In this class are also the references to the form defined.

Can you give me one more idea ??

Best regards
Frank Uray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top