Link to home
Start Free TrialLog in
Avatar of valvet
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=b77a5c561934e089' is not marked as serializable.

How do I get further now? I can't seem to get it right.

Thanks for reading.
SOLUTION
Avatar of naveenkohli
naveenkohli

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of valvet
valvet

ASKER

Hmm.

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.
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.
Avatar of valvet

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(HashtableObjectFromLibrary, SomeLocalHashtable);

Then do: o.Add(something, SomeLocalHashtable);
Avatar of valvet

ASKER

This is all done inside a thread in the main program which runs off an event from the library.
Avatar of valvet

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.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of valvet

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.Process' 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.