valvet
asked on
Serializing hashtable in library
Hello.
I'm trying to serialize my own hashtable which contains another hashtable object that's located in a library. I've marked most of the classes in the library as [Serializable], that appeard to be working at first, but at the end I get:
Failed to serialize. Reason: Type 'System.Threading.Thread' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56193 4e089' is not marked as serializable.
How do I get further now? I can't seem to get it right.
Thanks for reading.
I'm trying to serialize my own hashtable which contains another hashtable object that's located in a library. I've marked most of the classes in the library as [Serializable], that appeard to be working at first, but at the end I get:
Failed to serialize. Reason: Type 'System.Threading.Thread' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56193
How do I get further now? I can't seem to get it right.
Thanks for reading.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What kind of values are you putting in the Hashtable? If any of those includes a Thread it will be almost unpossible to serialize unless you do what naveenkohli suggests.
ASKER
I'm inserting a long value as the key, then the entire Hashtable object from the library as the value.
eg: o.Add(something, HashtableObjectFromLibrary );
Perhaps if I copied the HashtableObjectFromLibrary to a local temporary hashtable and then added that instead, so it would be like:
Copy(HashtableObjectFromLi brary, SomeLocalHashtable);
Then do: o.Add(something, SomeLocalHashtable);
eg: o.Add(something, HashtableObjectFromLibrary
Perhaps if I copied the HashtableObjectFromLibrary
Copy(HashtableObjectFromLi
Then do: o.Add(something, SomeLocalHashtable);
ASKER
This is all done inside a thread in the main program which runs off an event from the library.
ASKER
Well.
Now I tried changing it a bit, so now I'm storing the entire class from the library as an object in the Hashtable.
o.add(something, objectofclass);
I'm still getting threading issues. Is this realted to my events? They're of type public delegate and public event, which the main program has a thread running on.
Now I tried changing it a bit, so now I'm storing the entire class from the library as an object in the Hashtable.
o.add(something, objectofclass);
I'm still getting threading issues. Is this realted to my events? They're of type public delegate and public event, which the main program has a thread running on.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hehe, you\re right. Marking the delegates and events dident work, but doing it on the private declarations Thread, ManualResetEvent got past that.. now it complains about:
Failed to serialize. Reason: Type 'System.Diagnostics.Proces s' in Assembly 'Sys
This could go very far.
Ill just keep going marking everything as NonSerialize.
Let me see if I can figure out how to split this.
Failed to serialize. Reason: Type 'System.Diagnostics.Proces
This could go very far.
Ill just keep going marking everything as NonSerialize.
Let me see if I can figure out how to split this.
ASKER
The only public thread related is a propery field:
public ThreadPriority ThreadPriority
{
..
}
which I can set from the main program referencing the library.
The rest are either private or internal. I'll try and remove this priority and see what happends.
I should mention that I have some events in the library which the main program uses. These two are public delegate and public event.