NonSerialized System.Diagnostics.Process member

S

Steve Bloomfield

I have a Serializeable class with a public member variable of type
System.Diagnostics.Process. I don't want to serialize this, nor is it
possible to serialize it. So I added the [NonSerialized] attribute to
the type. But, I'm still getting an exception that I am trying to
serialize the Process class.

To be specific:
System.InvalidOperationException: The type
'System.Diagnostics.Process' cannot be serialized because its
parameterless constructor is decorated with declarative security
permission attributes. Consider using imperative asserts or demands in
the constructor.

If I change the variable to private instead of public then it works,
but I need this to be public. I tried using a private variable with a
public, read-only property and it tries serialize it. I tried
wrapping the Process member inside a non-serialized class and it tries
to serialize it.

I am using serialization with MSMQ and have not tried serializing to a
file.
 

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