Howto: Programmatically serialization Entry Method Parameters ( their values ) ?

P

Pawel

Howto: Programmatically serialization Entry Method Parameters ( their
values ) ?

See example below:





public static void C(string Code, string Name) {

// i will dynamic (programmatically) serialization method entry parameters -
( their values )

StackTrace t = new StackTrace(true);

StackFrame ff = t.GetFrame(0);

foreach (ParameterInfo pi in ff.GetMethod().GetParameters())

{

Stream stream = File.Create("C:\\a.xml");

SoapFormatter soap = new SoapFormatter();


// soap.Serialize(stream, values of entry parameters );

stream.Close();

}


return;

}



Regards,

P.
 
N

Nicholas Paldino [.NET/C# MVP]

Pawel,

You can't do that. The StackFrame doesn't offer up access to the
parameter values. Unless you hook into the runtime (or pass them explicitly
to your method) there is no way you will be able to do this.

Additionally, if this is a general mechanism, it is most likely going to
fail, as not all types in the framework are marked as serializable.

Hope this helps.
 
P

Pawel

Thanks.

Regards,
P.


U¿ytkownik "Nicholas Paldino [.NET/C# MVP]"
Pawel,

You can't do that. The StackFrame doesn't offer up access to the
parameter values. Unless you hook into the runtime (or pass them
explicitly to your method) there is no way you will be able to do this.

Additionally, if this is a general mechanism, it is most likely going
to fail, as not all types in the framework are marked as serializable.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Pawel said:
Howto: Programmatically serialization Entry Method Parameters ( their
values ) ?

See example below:





public static void C(string Code, string Name) {

// i will dynamic (programmatically) serialization method entry
parameters - ( their values )

StackTrace t = new StackTrace(true);

StackFrame ff = t.GetFrame(0);

foreach (ParameterInfo pi in ff.GetMethod().GetParameters())

{

Stream stream = File.Create("C:\\a.xml");

SoapFormatter soap = new SoapFormatter();


// soap.Serialize(stream, values of entry parameters );

stream.Close();

}


return;

}



Regards,

P.
 

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